Skip to content

Commit 3bc1676

Browse files
committed
Merge branch 'master' of github.com:biojava/biojava.github.io
* 'master' of github.com:biojava/biojava.github.io: More manual fixes More manual fixes Update BioJava:CookBook:PDB:header.md More manual fixes More manual fixes More backtick fixes
2 parents 5764804 + b3f8bb8 commit 3bc1676

6 files changed

+208
-196
lines changed

_wikis/BioJava:CookBook3:Stockholm.md

Lines changed: 86 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -14,97 +14,105 @@ multiple structure objects file, or an InputStream.
1414

1515
### To read a single object from a file, you can simply write
1616

17-
```java public static void main(String[] args){
18-
19-
`   try {`
20-
`       StockholmFileParser parser = new StockholmFileParser();`
21-
`       String pathName= "stockholmFilePathAndName";`
22-
`       StockholmStructure structure = parser.parse(pathName);`
23-
`           `
24-
`       //use read structures`
25-
`           `
26-
`   } catch (IOException e) {`
27-
`       e.printStackTrace();`
28-
`   } catch (Exception e) {`
29-
`       e.printStackTrace();`
30-
`   }`
31-
32-
} ```
17+
```java
18+
public static void main(String[] args){
19+
20+
   try {
21+
       StockholmFileParser parser = new StockholmFileParser();
22+
       String pathName= "stockholmFilePathAndName";
23+
       StockholmStructure structure = parser.parse(pathName);
24+
           
25+
       //use read structures
26+
           
27+
   } catch (IOException e) {
28+
       e.printStackTrace();
29+
   } catch (Exception e) {
30+
       e.printStackTrace();
31+
   }
32+
33+
}
34+
```
3335

3436
### Also you can read multiple alignments within the same file as follows
3537

36-
```java public static void main(String[] args){
37-
38-
`   try {`
39-
`       StockholmFileParser parser = new StockholmFileParser();`
40-
`       String sourcePath=settingsManager.getSourcePath();`
41-
`       String fileName= settingsManager.getFileName();`
42-
`       FileInputStream inStream = new FileInputStream(new File(sourcePath,fileName));`
43-
`       String outputPath=settingsManager.getOutputPath();`
44-
`       parser.parse(inStream,STRUCTURES_TO_SKIP);//if you don't want to start from first structure`
45-
`       do {`
46-
`           structures = parser.parse(inStream, MAX_PER_ITERATION);`
47-
`           for (int i = 0; i < structures.size(); i++) {`
48-
`               StockholmStructure structure = structures.get(i);`
49-
`               List`<AbstractSequence<? extends AbstractCompound>`> sequences = structure.getBioSequences(true);`
50-
`               final String accessionNumber = structure.getFileAnnotation().getAccessionNumber();`
51-
`               final String identification = structure.getFileAnnotation().getIdentification().toString();`
52-
`               manageRelatedSequences(accessionNumber, identification,sequences);`
53-
`           }`
54-
`       } while (structures.size()== MAX_PER_ITERATION);`
55-
`   } catch (FileNotFoundException e) {`
56-
`       e.printStackTrace();`
57-
`   } catch (IOException e) {`
58-
`       e.printStackTrace();`
59-
`   } catch (Exception e) {`
60-
`       e.printStackTrace();`
61-
`   }`
62-
63-
} ```
38+
```java
39+
public static void main(String[] args){
40+
41+
   try {
42+
       StockholmFileParser parser = new StockholmFileParser();
43+
       String sourcePath=settingsManager.getSourcePath();
44+
       String fileName= settingsManager.getFileName();
45+
       FileInputStream inStream = new FileInputStream(new File(sourcePath,fileName));
46+
       String outputPath=settingsManager.getOutputPath();
47+
       parser.parse(inStream,STRUCTURES_TO_SKIP);//if you don't want to start from first structure
48+
       do {
49+
           structures = parser.parse(inStream, MAX_PER_ITERATION);
50+
           for (int i = 0; i < structures.size(); i++) {
51+
               StockholmStructure structure = structures.get(i);
52+
               List<AbstractSequence<? extends AbstractCompound>> sequences = structure.getBioSequences(true);
53+
               final String accessionNumber = structure.getFileAnnotation().getAccessionNumber();
54+
               final String identification = structure.getFileAnnotation().getIdentification().toString();
55+
               manageRelatedSequences(accessionNumber, identification,sequences);
56+
           }
57+
       } while (structures.size()== MAX_PER_ITERATION);
58+
   } catch (FileNotFoundException e) {
59+
       e.printStackTrace();
60+
   } catch (IOException e) {
61+
       e.printStackTrace();
62+
   } catch (Exception e) {
63+
       e.printStackTrace();
64+
   }
65+
66+
}
67+
```
6468

6569
### Some times you don't have a reference to the file or input stream
6670

6771
Some times you use the parser in a place other than where it was
6872
created.
6973

70-
For example, you can create a StockholmFileParser in a function ```java
74+
For example, you can create a StockholmFileParser in a function
75+
76+
```java
7177

72-
`   public StockholmFileParser getStockholmFileParser(String filePathName) {`
73-
`       StockholmFileParser parser = new StockholmFileParser();`
74-
`       try {`
75-
`           parser.parse(filePathName, 0);`
76-
`       } catch (ParserException e) {`
77-
`           e.printStackTrace();`
78-
`       } catch (IOException e) {`
79-
`           e.printStackTrace();`
80-
`       }`
81-
`       return parser;`
82-
`   }`
78+
   public StockholmFileParser getStockholmFileParser(String filePathName) {
79+
       StockholmFileParser parser = new StockholmFileParser();
80+
       try {
81+
           parser.parse(filePathName, 0);
82+
       } catch (ParserException e) {
83+
           e.printStackTrace();
84+
       } catch (IOException e) {
85+
           e.printStackTrace();
86+
       }
87+
       return parser;
88+
   }
8389

8490
```
8591

8692
Then you use the created parser in another function, where you don't
87-
have a reference to its underling data source ```java
88-
89-
`   public void useParser(StockholmFileParser parser) {`
90-
`       final int MAX_PER_ITTERATION = 10;`
91-
`       List`<StockholmStructure>` structures;`
92-
`       long count= 0;`
93-
`       int successfullyRead = 0;`
94-
`       do {`
95-
`           try {`
96-
`               structures = parser.parseNext(MAX_PER_ITTERATION);`
97-
`               successfullyRead = structures.size();`
98-
`           } catch (IOException e) {`
99-
`               e.printStackTrace();`
100-
`           }`
101-
`           count += successfullyRead;`
102-
`           System.out.println("reached "+count);`
103-
`           `
104-
`           //use read structures`
105-
`           `
106-
`       } while (successfullyRead== MAX_PER_ITTERATION);`
107-
`       System.out.println("TOTAL COUNT = "+count);`
108-
`   }`
93+
have a reference to its underling data source
94+
95+
```java
96+
97+
   public void useParser(StockholmFileParser parser) {
98+
       final int MAX_PER_ITTERATION = 10;
99+
       List<StockholmStructure> structures;
100+
       long count= 0;
101+
       int successfullyRead = 0;
102+
       do {
103+
           try {
104+
               structures = parser.parseNext(MAX_PER_ITTERATION);
105+
               successfullyRead = structures.size();
106+
           } catch (IOException e) {
107+
               e.printStackTrace();
108+
           }
109+
           count += successfullyRead;
110+
           System.out.println("reached "+count);
111+
           
112+
           //use read structures
113+
           
114+
       } while (successfullyRead== MAX_PER_ITTERATION);
115+
       System.out.println("TOTAL COUNT = "+count);
116+
   }
109117

110118
```

_wikis/BioJava:CookBook:PDB:atomsCalc.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,24 @@ The
88
[Calc](http://www.biojava.org/docs/api/org/biojava/bio/structure/Calc.html)
99
class provides a set of methods that can be used for calculations.
1010

11-
```java public double getPhi(Group a, Group b)
11+
```java
12+
public double getPhi(Group a, Group b)
1213

13-
`   throws StructureException`
14-
`   {`
15-
`       `
16-
`       if ( ! Calc.isConnected(a,b)){`
17-
`           throw new StructureException("can not calc Phi - AminoAcids are not connected!") ;`
18-
`       } `
19-
`       `
20-
`       Atom a_C  = a.getAtom("C");`
21-
`       Atom b_N  = b.getAtom("N");`
22-
`       Atom b_CA = b.getAtom("CA");`
23-
`       Atom b_C  = b.getAtom("C");`
24-
`       `
25-
`       double phi = Calc.torsionAngle(a_C,b_N,b_CA,b_C);`
26-
`       return phi ;`
27-
`   }`
14+
   throws StructureException
15+
   {
16+
       
17+
       if ( ! Calc.isConnected(a,b)){
18+
           throw new StructureException("can not calc Phi - AminoAcids are not connected!") ;
19+
       } 
20+
       
21+
       Atom a_C  = a.getAtom("C");
22+
       Atom b_N  = b.getAtom("N");
23+
       Atom b_CA = b.getAtom("CA");
24+
       Atom b_C  = b.getAtom("C");
25+
       
26+
       double phi = Calc.torsionAngle(a_C,b_N,b_CA,b_C);
27+
       return phi ;
28+
   }
2829

2930
```
3031

_wikis/BioJava:CookBook:PDB:bioassembly.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,36 @@ Here some example code how to load the biological assembly:
2222

2323
```java
2424

25-
`           // good examples: 1stp 1gav 1hv4 1hho 7dfr 3fad  1qqp`
26-
27-
`           // assembly 0 ... asym Unit`
28-
`           // assembly 1 ... the first bio assembly`
29-
`           // example 1fah has  2 assemblies (two copies of the assembly in asymmetric unit)`
30-
`           `
31-
`           `
32-
`           // Various interesting symmetries: (see Lawson, 2008)`
33-
`           // Circular    - 1TJA`
34-
`           // Dihedral    - 1ei7`
35-
`           // Icosahedral - 1a34`
36-
`           // Helical     - 1cgm`
37-
`           `
38-
`           `
39-
`           // DNA 173D .. 2`
40-
`           `
41-
`           // we load the bio assembly info out of the PDB files`
42-
`           BioUnitDataProviderFactory.setBioUnitDataProvider(BioUnitDataProviderFactory.pdbProviderClassName);`
43-
44-
`           //Structure bioAssembly = StructureIO.getBiologicalAssembly("4A1I",2);  `
45-
`           `
46-
`           Structure bioAssembly = StructureIO.getBiologicalAssembly("1ei7",1);`
47-
`                                   `
48-
`           StructureAlignmentJmol jmolPanel = new StructureAlignmentJmol();`
49-
`           //jmolPanel.evalString("set autobond=false");`
50-
`           jmolPanel.setStructure(bioAssembly);`
51-
52-
`           // send some commands to Jmol`
53-
`           jmolPanel.evalString("select * ; color structure ; spacefill off; wireframe off; backbone off; cartoon on; select ligands ; spacefill 0.4; color cpk;");`
54-
`           `
55-
`           System.out.println("done!");`
25+
           // good examples: 1stp 1gav 1hv4 1hho 7dfr 3fad  1qqp
26+
27+
           // assembly 0 ... asym Unit
28+
           // assembly 1 ... the first bio assembly
29+
           // example 1fah has  2 assemblies (two copies of the assembly in asymmetric unit)
30+
           
31+
           
32+
           // Various interesting symmetries: (see Lawson, 2008)
33+
           // Circular    - 1TJA
34+
           // Dihedral    - 1ei7
35+
           // Icosahedral - 1a34
36+
           // Helical     - 1cgm
37+
           
38+
           
39+
           // DNA 173D .. 2
40+
           
41+
           // we load the bio assembly info out of the PDB files
42+
           BioUnitDataProviderFactory.setBioUnitDataProvider(BioUnitDataProviderFactory.pdbProviderClassName);
43+
44+
           //Structure bioAssembly = StructureIO.getBiologicalAssembly("4A1I",2);  
45+
           
46+
           Structure bioAssembly = StructureIO.getBiologicalAssembly("1ei7",1);
47+
                                   
48+
           StructureAlignmentJmol jmolPanel = new StructureAlignmentJmol();
49+
           //jmolPanel.evalString("set autobond=false");
50+
           jmolPanel.setStructure(bioAssembly);
51+
52+
           // send some commands to Jmol
53+
           jmolPanel.evalString("select * ; color structure ; spacefill off; wireframe off; backbone off; cartoon on; select ligands ; spacefill 0.4; color cpk;");
54+
           
55+
           System.out.println("done!");
5656

5757
```

_wikis/BioJava:CookBook:PDB:header.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@ class that can be accessed from
1313

1414
```java
1515

16-
`   public static void main(String[] args) throws Exception {`
17-
`       `
18-
`       String code =  "1aoi";`
19-
20-
`       AtomCache cache = new AtomCache();`
21-
`       `
22-
`       Structure struc = cache.getStructure(code);`
23-
`       `
24-
`       PDBHeader header = struc.getPDBHeader();`
25-
`       `
26-
`       System.out.println(header.toString());`
27-
`       `
28-
`       System.out.println("available compounds:");`
29-
`       List`<Compound>` compounds = struc.getCompounds();`
30-
`       for (Compound compound:compounds){`
31-
`           System.out.println(compound);`
32-
`       }`
33-
`       `
34-
`   }`
16+
   public static void main(String[] args) throws Exception {
17+
       
18+
       String code =  "1aoi";
19+
20+
       AtomCache cache = new AtomCache();
21+
       
22+
       Structure struc = cache.getStructure(code);
23+
       
24+
       PDBHeader header = struc.getPDBHeader();
25+
       
26+
       System.out.println(header.toString());
27+
       
28+
       System.out.println("available compounds:");
29+
       List<Compound> compounds = struc.getCompounds();
30+
       for (Compound compound:compounds){
31+
           System.out.println(compound);
32+
       }
33+
       
34+
   }
3535

3636
```
3737

_wikis/BioJava:CookBook:PDB:mmcif.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -133,31 +133,32 @@ load your own, custom data structures. For this you will require to
133133
implement the [MMcifConsumer
134134
interface](http://www.biojava.org/docs/api/org/biojava/bio/structure/io/mmcif/MMcifConsumer.html)
135135

136-
```java @since 1.7
136+
```java
137+
@since 1.7
137138

138-
`   public static void main(String[] args){`
139+
   public static void main(String[] args){
139140

140-
`       String fileName = args[0];`
141-
`       `
142-
`       InputStream inStream =  new FileInputStream(fileName);`
143-
`       `
144-
`       MMcifParser parser = new SimpleMMcifParser();`
141+
       String fileName = args[0];
142+
       
143+
       InputStream inStream =  new FileInputStream(fileName);
144+
       
145+
       MMcifParser parser = new SimpleMMcifParser();
145146

146-
`       SimpleMMcifConsumer consumer = new SimpleMMcifConsumer();`
147+
       SimpleMMcifConsumer consumer = new SimpleMMcifConsumer();
147148

148-
`       // The Consumer builds up the BioJava - structure object.`
149-
`               // you could also hook in your own and build up you own data model.          `
150-
`       parser.addMMcifConsumer(consumer);`
149+
       // The Consumer builds up the BioJava - structure object.
150+
               // you could also hook in your own and build up you own data model.          
151+
       parser.addMMcifConsumer(consumer);
151152

152-
`       try {`
153-
`           parser.parse(new BufferedReader(new InputStreamReader(inStream)));`
154-
`       } catch (IOException e){`
155-
`           e.printStackTrace();`
156-
`       }`
153+
       try {
154+
           parser.parse(new BufferedReader(new InputStreamReader(inStream)));
155+
       } catch (IOException e){
156+
           e.printStackTrace();
157+
       }
157158

158-
`               // now get the protein structure.`
159-
`       Structure cifStructure = consumer.getStructure();`
160-
`                     `
159+
               // now get the protein structure.
160+
       Structure cifStructure = consumer.getStructure();
161+
                     
161162

162163
}
163164

0 commit comments

Comments
 (0)