Skip to content

Commit aeb2344

Browse files
committed
Format and improve SS support
1 parent 52f41f4 commit aeb2344

15 files changed

Lines changed: 770 additions & 615 deletions

File tree

biojava-structure/src/main/java/demo/DemoLoadSecStruc.java

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,60 +21,63 @@
2121
package demo;
2222

2323
import java.io.IOException;
24+
import java.util.List;
2425

25-
import org.biojava.nbio.structure.Chain;
26-
import org.biojava.nbio.structure.Group;
2726
import org.biojava.nbio.structure.Structure;
2827
import org.biojava.nbio.structure.StructureException;
2928
import org.biojava.nbio.structure.align.util.AtomCache;
3029
import org.biojava.nbio.structure.io.FileParsingParameters;
3130
import org.biojava.nbio.structure.secstruc.DSSPParser;
3231
import org.biojava.nbio.structure.secstruc.SecStrucInfo;
32+
import org.biojava.nbio.structure.secstruc.SecStrucTools;
3333

3434
/**
35-
* Demonstration of how to load a Structure with the SS information,
36-
* either from the PDB file annotation (Author's assignment) or from
37-
* the DSSP file in the PDB servers (DSSP assignment).
35+
* Demonstration of how to load a Structure with the SS information, either from
36+
* the PDB file annotation (Author's assignment) or from the DSSP file in the
37+
* PDB servers (DSSP assignment).
3838
*
3939
* @author Aleix Lafita
4040
*
4141
*/
4242
public class DemoLoadSecStruc {
43-
44-
public static void main(String[] args)
45-
throws IOException, StructureException {
46-
47-
String pdbID = "5pti";
48-
49-
FileParsingParameters params = new FileParsingParameters();
50-
//Only change needed to the normal Structure loading
51-
params.setParseSecStruc(true); //this is false as DEFAULT
5243

53-
AtomCache cache = new AtomCache();
54-
cache.setFileParsingParams(params);
55-
cache.setUseMmCif(false);
44+
public static void main(String[] args) throws IOException,
45+
StructureException {
5646

57-
//The loaded Structure contains the SS assigned by Author
58-
Structure s = cache.getStructure(pdbID);
59-
60-
//If the more detailed DSSP prediction is required call this
61-
DSSPParser.fetch(pdbID, s, true);
47+
String pdbID = "5pti";
6248

63-
//Print the assignment residue by residue
64-
System.out.println("Residue assignment: ");
65-
for (Chain c : s.getChains()) {
66-
for (Group g: c.getAtomGroups()){
49+
// Only change needed to the DEFAULT Structure loading
50+
FileParsingParameters params = new FileParsingParameters();
51+
params.setParseSecStruc(true);
6752

68-
if (g.hasAminoAtoms()){
53+
AtomCache cache = new AtomCache();
54+
cache.setFileParsingParams(params);
6955

70-
SecStrucInfo ss =
71-
(SecStrucInfo) g.getProperty(Group.SEC_STRUC);
56+
// Use PDB format, because SS cannot be parsed from mmCIF yet
57+
cache.setUseMmCif(false);
7258

73-
System.out.println(c.getChainID() +
74-
" " + g.getResidueNumber() + " "
75-
+ g.getPDBName() + " -> " + ss);
76-
}
77-
}
78-
}
79-
}
59+
// The loaded Structure contains the SS assigned by Author (simple)
60+
Structure s = cache.getStructure(pdbID);
61+
62+
// Print the Author's assignment (from PDB file)
63+
System.out.println("Author's assignment: ");
64+
List<SecStrucInfo> ssi = SecStrucTools.getSecStrucInfo(s);
65+
for (SecStrucInfo ss : ssi) {
66+
System.out.println(ss.getGroup().getChain().getChainID() + " "
67+
+ ss.getGroup().getResidueNumber() + " "
68+
+ ss.getGroup().getPDBName() + " -> " + ss.toString());
69+
}
70+
71+
// If the more detailed DSSP prediction is required call this
72+
DSSPParser.fetch(pdbID, s, true);
73+
74+
// Print the assignment residue by residue
75+
System.out.println("DSSP assignment: ");
76+
ssi = SecStrucTools.getSecStrucInfo(s);
77+
for (SecStrucInfo ss : ssi) {
78+
System.out.println(ss.getGroup().getChain().getChainID() + " "
79+
+ ss.getGroup().getResidueNumber() + " "
80+
+ ss.getGroup().getPDBName() + " -> " + ss.toString());
81+
}
82+
}
8083
}

biojava-structure/src/main/java/demo/DemoSecStrucPred.java

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,37 @@
2020
*/
2121
public class DemoSecStrucPred {
2222

23-
public static void main(String[] args)
24-
throws IOException, StructureException {
25-
26-
String pdbID = "5pti";
27-
28-
AtomCache cache = new AtomCache();
29-
30-
//Load structure without any SS assignment
31-
Structure s = cache.getStructure(pdbID);
32-
33-
//Predict and assign the SS of the Structure
34-
SecStrucPred ssp = new SecStrucPred();
35-
ssp.predict(s, true);
36-
37-
//Print the DSSP output
38-
System.out.println("******DSSP output: ");
39-
System.out.println(ssp.printDSSP());
40-
41-
//Print the FASTA sequence of SS
42-
System.out.println("\n******FASTA output: ");
43-
System.out.println(ssp.printFASTA());
44-
45-
//Print the Helix Summary
46-
System.out.println("\n******Helix Summary: ");
47-
System.out.println(ssp.printHelixSummary());
48-
49-
//Obtain and print the SS elements of the Structure
50-
List<SecStrucElement> sse = SecStrucTools.getSSE(s);
51-
System.out.println("\n******SecStrucElements: ");
52-
for (SecStrucElement e : sse) System.out.println(e);
53-
54-
}
23+
public static void main(String[] args) throws IOException,
24+
StructureException {
25+
26+
String pdbID = "5pti";
27+
28+
AtomCache cache = new AtomCache();
29+
30+
// Load structure without any SS assignment
31+
Structure s = cache.getStructure(pdbID);
32+
33+
// Predict and assign the SS of the Structure
34+
SecStrucPred ssp = new SecStrucPred();
35+
ssp.predict(s, true);
36+
37+
// Print the DSSP output
38+
System.out.println("******DSSP output: ");
39+
System.out.println(ssp.printDSSP());
40+
41+
// Print the FASTA sequence of SS
42+
System.out.println("\n******FASTA output: ");
43+
System.out.println(ssp.printFASTA());
44+
45+
// Print the Helix Summary
46+
System.out.println("\n******Helix Summary: ");
47+
System.out.println(ssp.printHelixSummary());
48+
49+
// Obtain and print the SS elements of the Structure
50+
List<SecStrucElement> sse = SecStrucTools.getSecStrucElements(s);
51+
System.out.println("\n******SecStrucElements: ");
52+
for (SecStrucElement e : sse)
53+
System.out.println(e);
54+
55+
}
5556
}

0 commit comments

Comments
 (0)