Skip to content

Commit 22cfb22

Browse files
committed
Update/fix examples in structure-data-model
1 parent ac806c2 commit 22cfb22

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

structure/structure-data-model.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Structure
2828
All `Structure` objects contain one or more `Models`. That means also X-ray structures contain a "virtual" model which serves as a container for the chains. This allows to represent multi-model X-ray structures, e.g. from time-series analysis. The most common way to access chains is via:
2929

3030
```java
31-
List <Chain> chains = structure.getChains();
31+
List<Chain> chains = structure.getChains();
3232
```
3333

3434
This works for both NMR and X-ray based structures and by default the first `Model` is getting accessed.
@@ -58,7 +58,7 @@ Here an example that loops over the whole data model and prints out the HEM grou
5858

5959
for (Chain c : chains) {
6060

61-
System.out.println(" Chain: " + c.getChainID() + " # groups with atoms: " + c.getAtomGroups().size());
61+
System.out.println(" Chain: " + c.getId() + " # groups with atoms: " + c.getAtomGroups().size());
6262

6363
for (Group g: c.getAtomGroups()){
6464

@@ -87,35 +87,35 @@ The [Group](http://www.biojava.org/docs/api/org/biojava/nbio/structure/Group.htm
8787
In order to get all amino acids that have been observed in a PDB chain, you can use the following utility method:
8888

8989
```java
90-
Chain chain = s.getChainByPDB("A");
91-
List<Group> groups = chain.getAtomGroups("amino");
90+
Chain chain = structure.getPolyChainByPDB("A");
91+
List<Group> groups = chain.getAtomGroups(GroupType.AMINOACID);
9292
for (Group group : groups) {
93-
AminoAcid aa = (AminoAcid) group;
93+
SecStrucInfo secStrucInfo = (SecStrucInfo) group.getProperty(Group.SEC_STRUC);
9494

95-
// do something amino acid specific, e.g. print the secondary structure assignment
96-
System.out.println(aa + " " + aa.getSecStruc());
95+
// print the secondary structure assignment
96+
System.out.println(group + " -- " + secStrucInfo);
9797
}
9898
```
9999

100100
In a similar way you can access all nucleotide groups by
101101
```java
102-
chain.getAtomGroups("nucleotide");
102+
chain.getAtomGroups(GroupType.NUCLEOTIDE);
103103
```
104104

105105
The Hetatom groups are access in a similar fashion:
106106
```java
107-
chain.getAtomGroups("hetatm");
107+
chain.getAtomGroups(GroupType.HETATM);
108108
```
109109

110110

111111
Since all 3 types of groups are implementing the Group interface, you can also iterate over all groups and check for the instance type:
112112

113113
```java
114114
List<Group> allgroups = chain.getAtomGroups();
115-
for (Group group : groups) {
116-
if ( group instanceof AminoAcid) {
117-
AminoAcid aa = (AminoAcid) group;
118-
System.out.println(aa.getSecStruc());
115+
for (Group group : allgroups) {
116+
if (group.isAminoAcid()) {
117+
SecStrucInfo secStrucInfo = (SecStrucInfo) group.getProperty(Group.SEC_STRUC);
118+
System.out.println(group + " -- " + secStrucInfo);
119119
}
120120
}
121121
```

0 commit comments

Comments
 (0)