2121package demo ;
2222
2323import java .io .IOException ;
24+ import java .util .List ;
2425
25- import org .biojava .nbio .structure .Chain ;
26- import org .biojava .nbio .structure .Group ;
2726import org .biojava .nbio .structure .Structure ;
2827import org .biojava .nbio .structure .StructureException ;
2928import org .biojava .nbio .structure .align .util .AtomCache ;
3029import org .biojava .nbio .structure .io .FileParsingParameters ;
3130import org .biojava .nbio .structure .secstruc .DSSPParser ;
3231import 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 */
4242public 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}
0 commit comments