Skip to content

Commit e3b8dd6

Browse files
committed
looping over the whole data model
1 parent e19ba0c commit e3b8dd6

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

structure/structure-data-model.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,47 @@ If you want to directly access an array of [Atoms](http://www.biojava.org/docs/a
4747

4848
Alternatively you can access atoms also by their parent-group.
4949

50-
## Loop over all the data
50+
## Compounds (Entities) and Chains
5151

5252
//TODO
5353

54+
## Loop over all the data
55+
56+
Here an example that loops over the whole data model and prints out the HEM groups of hemoglobin:
57+
58+
<pre>
59+
Structure structure = StructureIO.getStructure("4hhb");
60+
61+
System.out.println(" # of compounds (entities) " + structure.getCompounds().size());
62+
63+
for ( Compound entity: structure.getCompounds()) {
64+
System.out.println(" " + entity);
65+
}
66+
List<Chain> chains = structure.getChains();
67+
68+
System.out.println(" # chains: " + chains.size());
69+
70+
for (Chain c : chains) {
71+
System.out.println(" Chain: " + c.getChainID());
72+
for (Group g: c.getAtomGroups()){
73+
74+
if ( g.getPDBName().equalsIgnoreCase("HEM")) {
75+
76+
System.out.println(g);
77+
78+
for (Atom a: g.getAtoms()) {
79+
80+
System.out.println(a);
81+
82+
}
83+
84+
}
85+
86+
}
87+
}
88+
</pre>
89+
90+
5491
## Working with groups
5592

5693
The [Group](http://www.biojava.org/docs/api/org/biojava/bio/structure/Group.html) interface defines all methods common to a group of atoms. There are 3 types of Groups:

0 commit comments

Comments
 (0)