Skip to content

Commit c290ea9

Browse files
committed
wip (most of structure parsing done)
1 parent e3bad37 commit c290ea9

File tree

115 files changed

+3085
-15238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+3085
-15238
lines changed

biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/util/PDBUploadPanel.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.biojava.nbio.structure.StructureException;
2727
import org.biojava.nbio.structure.StructureTools;
2828
import org.biojava.nbio.structure.align.util.UserConfiguration;
29-
import org.biojava.nbio.structure.io.MMCIFFileReader;
3029
import org.biojava.nbio.structure.io.PDBFileReader;
3130
import org.biojava.nbio.structure.io.StructureIOFile;
3231
import org.slf4j.Logger;

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

Lines changed: 20 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,33 @@
2323
import org.biojava.nbio.structure.Chain;
2424
import org.biojava.nbio.structure.Group;
2525
import org.biojava.nbio.structure.Structure;
26+
import org.biojava.nbio.structure.chem.AllChemCompProvider;
27+
import org.biojava.nbio.structure.chem.ChemCompGroupFactory;
28+
import org.biojava.nbio.structure.chem.ChemCompProvider;
29+
import org.biojava.nbio.structure.chem.DownloadChemCompProvider;
2630
import org.biojava.nbio.structure.io.FileParsingParameters;
2731
import org.biojava.nbio.structure.io.PDBFileReader;
28-
import org.biojava.nbio.structure.io.mmcif.AllChemCompProvider;
29-
import org.biojava.nbio.structure.io.mmcif.ChemCompGroupFactory;
30-
import org.biojava.nbio.structure.io.mmcif.ChemCompProvider;
31-
import org.biojava.nbio.structure.io.mmcif.DownloadChemCompProvider;
3232

3333
import java.util.List;
3434

35-
3635
/**
37-
* This demo shows how to use an alternative ChemCompProvider. The default mechanism in BioJava is to access chemical components
38-
* by using the {@link DownloadChemCompProvider}. It fetches and locally caches chemical component definitions as they are encountered during file parsing.
39-
* It can be enabled by using the {@link FileParsingParameters#setLoadChemCompInfo(boolean)} method.
36+
* This demo shows how to use an alternative ChemCompProvider. The default mechanism in BioJava is to access chemical
37+
* componentsby using the {@link DownloadChemCompProvider}. It fetches and locally caches chemical component
38+
* definitions as they are encountered during file parsing. It can be enabled by using the
39+
* {@link FileParsingParameters#setLoadChemCompInfo(boolean)} method.
4040
*
41-
* The {@link AllChemCompProvider} downloads and unpacks all chemcomps. It is slower and requires more memory than the default {@link DownloadChemCompProvider},
42-
* but it avoids network access to the FTP site, if a new chemcomp is detected, that has not been downloaded yet.
41+
* The {@link AllChemCompProvider} downloads and unpacks all chemcomps. It is slower and requires more memory than the
42+
* default {@link DownloadChemCompProvider}, but it avoids network access to the FTP site, if a new chemcomp is
43+
* detected, that has not been downloaded yet.
4344
*
4445
* Since all chemcomps will be kept in memory, the standard memory that is available to a JVM will not be sufficient
4546
* in order to run this demo. Please start with -Xmx200M
4647
*
4748
* @author Andreas Prlic
48-
*
4949
*/
5050
public class DemoChangeChemCompProvider {
51-
5251
public static void main(String[] args){
5352
String pdbId = "1O1G";
54-
5553
boolean loadChemComp = true;
5654

5755
//////
@@ -66,82 +64,60 @@ public static void main(String[] args){
6664
// or via
6765
// by setting the PDB_PATH environmental variable or system property
6866
// when running the demo (e.g. -DPDB_DIR=/path/to/pdb)
69-
70-
if ( loadChemComp) {
71-
67+
if (loadChemComp) {
7268
// The AllChemCompProvider loads all chem comps at startup.
7369
// This is slow (13 sec on my laptop) and requires more
7470
// memory than the default DownloadChemCompProvider.
7571
// In contrast to it it keeps all definitions in memory.
7672
ChemCompProvider all = new AllChemCompProvider();
77-
7873
ChemCompGroupFactory.setChemCompProvider(all);
7974
}
8075

8176
DemoChangeChemCompProvider demo = new DemoChangeChemCompProvider();
8277

8378
// run the demo
84-
demo.basicLoad(reader,loadChemComp, pdbId);
85-
79+
demo.basicLoad(reader, pdbId);
8680
}
8781

88-
public void basicLoad(PDBFileReader reader, boolean loadChemComp, String pdbId){
89-
82+
public void basicLoad(PDBFileReader reader, String pdbId) {
9083
try {
9184
// configure the parameters of file parsing
92-
9385
FileParsingParameters params = new FileParsingParameters();
94-
9586
// should the ATOM and SEQRES residues be aligned when creating the internal data model?
9687
// only do this if you need to work with SEQRES sequences. If all you need are ATOMs, then
9788
// set it to false to have quicker file loading.
9889
params.setAlignSeqRes(true);
9990

100-
//
10191
// should secondary structure get parsed from the file
10292
params.setParseSecStruc(false);
103-
10493
reader.setFileParsingParameters(params);
105-
10694
Structure struc = reader.getStructureById(pdbId);
107-
10895
printStructure(struc);
109-
110-
11196
} catch (Exception e){
11297
e.printStackTrace();
11398
}
114-
11599
}
116100

117101
private void printStructure(Structure struc) {
118-
119102
System.out.println(struc);
120-
121-
//Chain c = struc.getChainByPDB("C");
122103
String pdbid = struc.getPDBCode();
123104
for (int i = 0; i < struc.nrModels(); i++) {
124-
125105
// loop chain
126106
for (Chain ch : struc.getModel(i)) {
127-
if (! ch.getName().equals("A") )
107+
if (!ch.getName().equals("A")) {
128108
continue;
129-
System.out.println(pdbid + ">>>" + ch.getName() + ">>>"
130-
+ ch.getAtomSequence());
131-
System.out.println(pdbid + ">>>" + ch.getName() + ">>>"
132-
+ ch.getSeqResSequence());
109+
}
110+
System.out.println(pdbid + ">>>" + ch.getName() + ">>>" + ch.getAtomSequence());
111+
System.out.println(pdbid + ">>>" + ch.getName() + ">>>" + ch.getSeqResSequence());
133112
// Test the getAtomGroups() and getSeqResGroups() method
134-
135113
List<Group> group = ch.getSeqResGroups();
136114
int seqPos = 0;
137115
for (Group gp : group) {
138-
System.out.println(ch.getName() + ":"+seqPos + ":" + gp.getResidueNumber() + ":"
139-
+ gp.getPDBName() + " " + gp.getType());
116+
System.out.println(ch.getName() + ":" + seqPos + ":" + gp.getResidueNumber() + ":" +
117+
gp.getPDBName() + " " + gp.getType());
140118
seqPos++;
141119
}
142120
}
143121
}
144-
145-
146122
}
147123
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import org.biojava.nbio.structure.*;
2828
import org.biojava.nbio.structure.align.util.AtomCache;
29-
import org.biojava.nbio.structure.io.MMCIFFileReader;
3029
import org.biojava.nbio.structure.io.StructureProvider;
3130

3231
import java.util.List;

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

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323

2424
import org.biojava.nbio.structure.Chain;
2525
import org.biojava.nbio.structure.Structure;
26-
import org.biojava.nbio.structure.io.mmcif.MMcifParser;
27-
import org.biojava.nbio.structure.io.mmcif.SimpleMMcifConsumer;
28-
import org.biojava.nbio.structure.io.mmcif.SimpleMMcifParser;
2926

3027
import java.io.BufferedReader;
3128
import java.io.File;
@@ -38,42 +35,32 @@
3835
* An example of how to convert mmCIF file to PDB file
3936
*
4037
* @author Jose Duarte
41-
*
4238
*/
43-
public class DemoMmcifToPdbConverter
44-
{
45-
39+
public class DemoMmcifToPdbConverter {
4640
public static void main(String[] args) throws Exception {
47-
4841
File inFile = new File(args[0]);
4942
File outFile = new File(args[1]);
5043
convert(inFile, outFile);
5144
}
5245

53-
54-
5546
public static void convert(File inFile, File outFile) throws IOException {
56-
57-
MMcifParser parser = new SimpleMMcifParser();
58-
59-
SimpleMMcifConsumer consumer = new SimpleMMcifConsumer();
60-
parser.addMMcifConsumer(consumer);
61-
parser.parse(new BufferedReader(new InputStreamReader(new FileInputStream(inFile))));
62-
63-
// now get the protein structure.
64-
Structure cifStructure = consumer.getStructure();
65-
66-
// and write it out as PDB format
67-
PrintWriter pr = new PrintWriter(outFile);
68-
for (Chain c : cifStructure.getChains()) {
69-
// we can override the chain name, the mmCIF chain names might have more than 1 character
70-
c.setName(c.getName().substring(0, 1));
71-
pr.print(c.toPDB());
72-
pr.println("TER");
73-
}
47+
MMcifParser parser = new SimpleMMcifParser();
48+
SimpleMMcifConsumer consumer = new SimpleMMcifConsumer();
49+
parser.addMMcifConsumer(consumer);
50+
parser.parse(new BufferedReader(new InputStreamReader(new FileInputStream(inFile))));
51+
52+
// now get the protein structure.
53+
Structure cifStructure = consumer.getStructure();
54+
55+
// and write it out as PDB format
56+
PrintWriter pr = new PrintWriter(outFile);
57+
for (Chain c : cifStructure.getChains()) {
58+
// we can override the chain name, the mmCIF chain names might have more than 1 character
59+
c.setName(c.getName().substring(0, 1));
60+
pr.print(c.toPDB());
61+
pr.println("TER");
62+
}
7463

7564
pr.close();
76-
77-
7865
}
7966
}

biojava-structure/src/main/java/org/biojava/nbio/structure/AtomPositionMap.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@
3232
import java.util.NavigableMap;
3333
import java.util.TreeMap;
3434

35-
import org.biojava.nbio.structure.io.mmcif.chem.PolymerType;
36-
import org.biojava.nbio.structure.io.mmcif.chem.ResidueType;
37-
import org.biojava.nbio.structure.io.mmcif.model.ChemComp;
35+
import org.biojava.nbio.structure.chem.PolymerType;
36+
import org.biojava.nbio.structure.chem.ResidueType;
3837
import org.slf4j.Logger;
3938
import org.slf4j.LoggerFactory;
4039

biojava-structure/src/main/java/org/biojava/nbio/structure/Chain.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import org.biojava.nbio.core.sequence.template.Sequence;
2727
import org.biojava.nbio.structure.io.FileParsingParameters;
28-
import org.biojava.nbio.structure.io.mmcif.model.ChemComp;
2928

3029
import java.io.Serializable;
3130
import java.util.List;

biojava-structure/src/main/java/org/biojava/nbio/structure/ChainImpl.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
package org.biojava.nbio.structure;
2525

2626

27+
import org.biojava.nbio.structure.chem.ChemCompGroupFactory;
28+
import org.biojava.nbio.structure.chem.PolymerType;
2729
import org.biojava.nbio.structure.io.FileConvert;
28-
import org.biojava.nbio.structure.io.mmcif.ChemCompGroupFactory;
29-
import org.biojava.nbio.structure.io.mmcif.chem.PolymerType;
30-
import org.biojava.nbio.structure.io.mmcif.model.ChemComp;
3130
import org.biojava.nbio.core.exceptions.CompoundNotFoundException;
3231
import org.biojava.nbio.core.sequence.ProteinSequence;
3332
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound;
@@ -686,7 +685,7 @@ public String toPDB() {
686685

687686
@Override
688687
public String toMMCIF() {
689-
return FileConvert.toMMCIF(this, true);
688+
return FileConvert.toMMCIF(this);
690689
}
691690

692691
@Override
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package org.biojava.nbio.structure;
2+
3+
import org.biojava.nbio.structure.io.cif.CifBean;
4+
5+
import java.util.ArrayList;
6+
import java.util.List;
7+
8+
public class DatabasePDBRevRecord implements CifBean<org.rcsb.cif.schema.mm.DatabasePDBRevRecord> {
9+
private static final long serialVersionUID = 1L;
10+
private String revNum;
11+
private String type;
12+
private String details;
13+
14+
public DatabasePDBRevRecord() {
15+
16+
}
17+
18+
public DatabasePDBRevRecord(String revNum, String type, String details) {
19+
this.revNum = revNum;
20+
this.type = type;
21+
this.details = details;
22+
}
23+
24+
public DatabasePDBRevRecord(org.rcsb.cif.schema.mm.DatabasePDBRevRecord cif, int row) {
25+
this(cif.getDetails().get(row),
26+
cif.getRevNum().getStringData(row),
27+
cif.getType().get(row));
28+
}
29+
30+
public String getRevNum() {
31+
return revNum;
32+
}
33+
34+
public void setRevNum(String revNum) {
35+
this.revNum = revNum;
36+
}
37+
38+
public String getType() {
39+
return type;
40+
}
41+
42+
public void setType(String type) {
43+
this.type = type;
44+
}
45+
46+
public String getDetails() {
47+
return details;
48+
}
49+
50+
public void setDetails(String details) {
51+
this.details = details;
52+
}
53+
54+
@Override
55+
public String toString() {
56+
return "DatabasePDBRevRecord{" +
57+
"revNum='" + revNum + '\'' +
58+
", type='" + type + '\'' +
59+
", details='" + details + '\'' +
60+
'}';
61+
}
62+
}

biojava-structure/src/main/java/org/biojava/nbio/structure/DatabasePdbRevRecord.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)