ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/branches/aglappe-jung/testGetChains.java
Revision: 441
Committed: Thu Nov 29 15:19:37 2007 UTC (16 years, 10 months ago) by duarte
File size: 4542 byte(s)
Log Message:
Now Pdb constructors don't load data but rather intialise the pdbCode, loading occurs upon call of load(pdbChainCode,modelSerial)
New methods getChains() and getModels() in all Pdb classes
New Exception PdbLoadError
New tester for getChains and getModels: testGetChains
Changed all calls to Pdb construction accordingly (includes changing excpetions)
Line User Rev File contents
1 duarte 441 import java.io.BufferedReader;
2     import java.io.File;
3     import java.io.FileReader;
4     import java.io.IOException;
5     import java.sql.SQLException;
6    
7     import proteinstructure.CiffilePdb;
8     //import proteinstructure.MsdsdPdb;
9     import proteinstructure.Pdb;
10     import proteinstructure.PdbCodeNotFoundError;
11     import proteinstructure.PdbLoadError;
12     import proteinstructure.PdbasePdb;
13     import proteinstructure.PdbfilePdb;
14     import tools.MySQLConnection;
15    
16    
17     public class testGetChains {
18    
19     public static void main(String[] args) throws IOException, SQLException{
20    
21     String pdbFilesDir = "/project/StruPPi/BiO/DBd/PDB-REMEDIATED/data/structures/unzipped/all/pdb";
22     String cifFilesDir = "/project/StruPPi/BiO/DBd/PDB-REMEDIATED/data/structures/unzipped/all/mmCIF";
23     MySQLConnection conn = new MySQLConnection("white","duarte","nieve");
24    
25     //String[] pdbCodes = {"12as", "3eca", "1bxy"} ;
26    
27     String listFile = "/project/StruPPi/jose/workspace/aglappe-jung/pdbcodes.testset";
28     BufferedReader fpdb = new BufferedReader(new FileReader(listFile));
29     String line;
30     while ((line=fpdb.readLine())!=null) {
31     String pdbCode = line.split("\t")[0].toLowerCase();
32    
33     System.out.println("pdb "+pdbCode);
34    
35     try {
36     Pdb pdbasepdb = new PdbasePdb(pdbCode, "pdbase", conn);
37     String[] pdbasechains = pdbasepdb.getChains();
38     Integer[] pdbasemodels = pdbasepdb.getModels();
39     pdbasepdb.load(pdbasechains[0]);
40    
41    
42     // Pdb msdsdpdb = new MsdsdPdb(pdbCode,"msdsd_00_07_a",conn);
43     // String[] msdsdchains = msdsdpdb.getChains();
44     // Integer[] msdsdmodels = msdsdpdb.getModels();
45     // msdsdpdb.load(msdsdchains[0]);
46    
47     Pdb ciffilepdb = new CiffilePdb(new File(cifFilesDir,pdbCode+".cif"));
48     String[] ciffilechains = ciffilepdb.getChains();
49     Integer[] ciffilemodels = ciffilepdb.getModels();
50     ciffilepdb.load(ciffilechains[0]);
51    
52    
53     Pdb pdbfilepdb = new PdbfilePdb(pdbFilesDir+"/pdb"+pdbCode+".ent");
54     String[] pdbfilechains = pdbfilepdb.getChains();
55     Integer[] pdbfilemodels = pdbfilepdb.getModels();
56     pdbfilepdb.load(pdbfilechains[0]);
57    
58    
59     // System.out.println("online cif file...");
60     // pdb = new CiffilePdb(pdbCode);
61     // allChains = pdb.getChains();
62     // System.out.print("pdb: "+pdbCode+", chains: ");
63     // for (String chain:allChains) {
64     // System.out.print(chain+ " ");
65     // }
66     // System.out.println();
67     // pdb.load("A");
68     // System.out.println("length:" + pdb.getFullLength());
69    
70     boolean chainsmatch = true;
71     boolean modelsmatch = true;
72     if (pdbasechains.length != ciffilechains.length || pdbasechains.length!= pdbfilechains.length ) { //|| pdbasechains.length!=msdsdchains.length) {
73     System.out.println("different number of chains");
74     chainsmatch=false;
75     }
76     else {
77     for (int i=0; i<pdbasechains.length;i++) {
78     if (!pdbasechains[i].equals(ciffilechains[i]) || !pdbasechains[i].equals(pdbfilechains[i]) ){ // || !pdbasechains[i].equals(msdsdchains[i])){
79     System.out.println("chain differs: pdbase "+pdbasechains[i]+", ciffile "+ciffilechains[i]+", pdbfile "+pdbfilechains[i]);//+", msdsd "+msdsdchains[i]);
80     chainsmatch=false;
81     }
82     }
83     }
84    
85     if (chainsmatch) {
86     for (String chain:pdbfilechains) {
87     System.out.print(chain+ " ");
88     }
89     System.out.println();
90    
91     if (pdbasepdb.getFullLength()!=ciffilepdb.getFullLength() || pdbasepdb.getFullLength()!=pdbfilepdb.getFullLength()){ // || pdbasepdb.getFullLength()!=msdsdpdb.getFullLength()) {
92     System.out.println("length for chain "+pdbfilechains[0]+" differs");
93     }
94     }
95    
96     if (pdbasemodels.length != ciffilemodels.length || pdbasemodels.length != pdbfilemodels.length ) {//|| pdbasemodels.length != msdsdmodels.length) {
97     System.out.println("different number of models");
98     modelsmatch = false;
99     } else {
100     for (int i=0;i<pdbasemodels.length;i++){
101     if (pdbasemodels[i]!=ciffilemodels[i] || pdbasemodels[i]!=pdbfilemodels[i] ){ //|| pdbasemodels[i]!=msdsdmodels[i]){
102     System.out.println("model differs: pdbase "+pdbasemodels[i]+", ciffile "+ciffilemodels[i]+", pdbfile "+pdbfilemodels[i]);//+", msdsd "+msdsdmodels[i]);
103     modelsmatch = false;
104     }
105     }
106     }
107     if (modelsmatch) {
108     for (int model:pdbasemodels) {
109     System.out.print(model+" ");
110     }
111     System.out.println();
112     }
113    
114    
115     } catch (PdbCodeNotFoundError e) {
116     System.err.println("pdb code was not found in pdbase");
117     } catch (PdbLoadError e) {
118     System.err.println("couldn't load pdb data, specific error: "+e.getMessage());
119     }
120     }
121     fpdb.close();
122    
123    
124    
125    
126    
127    
128     }
129    
130     }