@@ -98,11 +98,7 @@ private void comparePDB2cif(String id, String chainId) throws IOException {
9898
9999
100100 parser .addMMcifConsumer (consumer );
101- try {
102- parser .parse (new BufferedReader (new InputStreamReader (inStream )));
103- } catch (IOException e ){
104- fail (e .getMessage ());
105- }
101+ parser .parse (new BufferedReader (new InputStreamReader (inStream )));
106102 // remove to avoid memory leaks
107103 parser .clearConsumers ();
108104 Structure cifStructure = consumer .getStructure ();
@@ -124,98 +120,96 @@ private void comparePDB2cif(String id, String chainId) throws IOException {
124120 assertNotNull (pdbStructure );
125121
126122 // now compare the results
127- try {
128-
129- // chech NMR data
130- assertEquals (id + ": the isNMR flag is not the same!" , pdbStructure .isNmr (), cifStructure .isNmr ());
131123
132- if ( pdbStructure .isNmr ()){
133- assertEquals (id + ": the nr of NMR models is not the same!" , pdbStructure .nrModels (), pdbStructure .nrModels ());
134- checkNMR (pdbStructure );
135- checkNMR (cifStructure );
136- }
137124
138- //System.out.println(pdbStructure);
139- //System.out.println( cifStructure);
125+ // chech NMR data
126+ assertEquals ( id + ": the isNMR flag is not the same!" , pdbStructure . isNmr (), cifStructure . isNmr () );
140127
141- // compare amino acids in chain 1:
142- Chain a_pdb = pdbStructure .getChainByPDB (chainId );
143- Chain a_cif = cifStructure .getChainByPDB (chainId );
144- //System.out.println(a_pdb.getAtomGroups());
128+ if ( pdbStructure .isNmr ()){
129+ assertEquals (id + ": the nr of NMR models is not the same!" , pdbStructure .nrModels (), pdbStructure .nrModels ());
130+ checkNMR (pdbStructure );
131+ checkNMR (cifStructure );
132+ }
145133
146- //System.out.println(id + "_" + chainId + " pdb atom groups: " + a_pdb.getAtomGroups(GroupType.AMINOACID).size() );
147- //System.out.println(id + "_" + chainId + " cif atom groups: " + a_cif.getAtomGroups(GroupType.AMINOACID).size() );
134+ //System.out.println(pdbStructure );
135+ //System.out.println(cifStructure );
148136
149- //for (Group g: a_cif.getAtomGroups()){
150- // System.out.println(g);
151- //}
152- //System.out.println("--");
153- String pdb_SEQseq = a_pdb .getSeqResSequence ();
137+ // compare amino acids in chain 1:
138+ Chain a_pdb = pdbStructure .getPolyChainByPDB (chainId );
139+ Chain a_cif = cifStructure .getPolyChainByPDB (chainId );
140+ //System.out.println(a_pdb.getAtomGroups());
154141
155- String cif_SEQseq = a_cif .getSeqResSequence ();
142+ //System.out.println(id + "_" + chainName + " pdb atom groups: " + a_pdb.getAtomGroups(GroupType.AMINOACID).size());
143+ //System.out.println(id + "_" + chainName + " cif atom groups: " + a_cif.getAtomGroups(GroupType.AMINOACID).size());
156144
157- // System.out.println(id + "_" + chainId + " pdbSEQ: " + pdb_SEQseq);
158- // System.out.println(id + "_" + chainId + " cifSEQ: " + cif_SEQseq);
145+ //for (Group g: a_cif.getAtomGroups()){
146+ // System.out.println(g);
147+ //}
148+ //System.out.println("--");
149+ String pdb_SEQseq = a_pdb .getSeqResSequence ();
159150
160- assertEquals ( id + ": the SEQRES sequences don't match!" , pdb_SEQseq , cif_SEQseq );
151+ String cif_SEQseq = a_cif . getSeqResSequence ( );
161152
162- assertEquals (id + ": The nr of ATOM groups does not match!" ,a_pdb .getAtomGroups (GroupType .AMINOACID ).size (),a_cif .getAtomGroups (GroupType .AMINOACID ).size () );
153+ // System.out.println(id + "_" + chainName + " pdbSEQ: " + pdb_SEQseq);
154+ // System.out.println(id + "_" + chainName + " cifSEQ: " + cif_SEQseq);
163155
164- // actually this check not necessarily works, since there can be waters in PDB that we don;t deal with yet in cif...
165- //assertEquals("the nr of ATOM record groups is not the same!" , a_pdb.getAtomLength(),a_cif.getAtomLength());
166- for (int i = 0 ; i < a_pdb .getAtomGroups (GroupType .AMINOACID ).size (); i ++){
167- Group gp = a_pdb .getAtomGroups (GroupType .AMINOACID ).get (i );
156+ assertEquals (id + ": the SEQRES sequences don't match!" , pdb_SEQseq ,cif_SEQseq );
168157
169- List <Group > cifGroups = a_cif .getAtomGroups (GroupType .AMINOACID );
170- Group gc = cifGroups .get (i );
171- checkGroups (gp , gc );
172- }
158+ assertEquals (id + ": The nr of ATOM groups does not match!" ,a_pdb .getAtomGroups (GroupType .AMINOACID ).size (),a_cif .getAtomGroups (GroupType .AMINOACID ).size () );
173159
160+ // actually this check not necessarily works, since there can be waters in PDB that we don;t deal with yet in cif...
161+ //assertEquals("the nr of ATOM record groups is not the same!" , a_pdb.getAtomLength(),a_cif.getAtomLength());
162+ for (int i = 0 ; i < a_pdb .getAtomGroups (GroupType .AMINOACID ).size (); i ++){
163+ Group gp = a_pdb .getAtomGroups (GroupType .AMINOACID ).get (i );
174164
165+ List <Group > cifGroups = a_cif .getAtomGroups (GroupType .AMINOACID );
166+ Group gc = cifGroups .get (i );
167+ checkGroups (gp , gc );
168+ }
175169
176- String pdb_seq = a_pdb .getAtomSequence ();
177- String cif_seq = a_cif .getAtomSequence ();
178170
179- //System.out.println(pdb_seq);
180- //System.out.println(cif_seq);
181171
182- assertEquals ("the sequences obtained from PDB and mmCif don't match!" ,pdb_seq , cif_seq );
172+ String pdb_seq = a_pdb .getAtomSequence ();
173+ String cif_seq = a_cif .getAtomSequence ();
183174
184- List < DBRef > pdb_dbrefs = pdbStructure . getDBRefs ( );
185- List < DBRef > cif_dbrefs = cifStructure . getDBRefs ( );
175+ //System.out.println(pdb_seq );
176+ //System.out.println(cif_seq );
186177
187- assertEquals ("nr of DBrefs found does not match!" , pdb_dbrefs . size (), cif_dbrefs . size () );
178+ assertEquals ("the sequences obtained from PDB and mmCif don't match!" ,pdb_seq , cif_seq );
188179
189- DBRef p = pdb_dbrefs . get ( 0 );
190- DBRef c = cif_dbrefs . get ( 0 );
180+ List < DBRef > pdb_dbrefs = pdbStructure . getDBRefs ( );
181+ List < DBRef > cif_dbrefs = cifStructure . getDBRefs ( );
191182
192- //System.out.println(p.toPDB());
193- //System.out.println(c.toPDB());
194- String pdb_dbref = p .toPDB ();
195- String cif_dbref = c .toPDB ();
196- assertEquals ("DBRef is not equal" ,pdb_dbref ,cif_dbref );
183+ assertEquals ("nr of DBrefs found does not match!" , pdb_dbrefs .size (),cif_dbrefs .size ());
197184
198- PDBHeader h1 = pdbStructure . getPDBHeader ( );
199- PDBHeader h2 = cifStructure . getPDBHeader ( );
185+ DBRef p = pdb_dbrefs . get ( 0 );
186+ DBRef c = cif_dbrefs . get ( 0 );
200187
201- //compareString(h1.toPDB() ,h2.toPDB());
202- //System.out.println(h1.toPDB());
203- //System.out.println(h2.toPDB());
204- if ( ! h1 .toPDB ().toUpperCase ().equals (h2 .toPDB ().toUpperCase ()) ){
205- System .err .println (h1 .toPDB ());
206- System .err .println (h2 .toPDB ());
207- compareString (h1 .toPDB (), h2 .toPDB ());
208- }
209- assertEquals ("the PDBHeader.toPDB representation is not equivalent" , h1 .toPDB ().toUpperCase (),h2 .toPDB ().toUpperCase ());
188+ //System.out.println(p.toPDB());
189+ //System.out.println(c.toPDB());
190+ String pdb_dbref = p .toPDB ();
191+ String cif_dbref = c .toPDB ();
192+ assertEquals ("DBRef is not equal" ,pdb_dbref ,cif_dbref );
210193
211- // and the ultimate test!
212- // but we are not there yet...
213- // TODO: still need to parse SSBOND equivalent info from cif files...
214- //assertEquals("the Structure.toPDB representation is not equivalent", pdbStructure.toPDB(),cifStructure.toPDB());
194+ PDBHeader h1 = pdbStructure .getPDBHeader ();
195+ PDBHeader h2 = cifStructure .getPDBHeader ();
215196
216- } catch (StructureException ex ){
217- fail (ex .getMessage () + " for PDB: " + id );
197+ //compareString(h1.toPDB() ,h2.toPDB());
198+ //System.out.println(h1.toPDB());
199+ //System.out.println(h2.toPDB());
200+ if ( ! h1 .toPDB ().toUpperCase ().equals (h2 .toPDB ().toUpperCase ()) ){
201+ System .err .println (h1 .toPDB ());
202+ System .err .println (h2 .toPDB ());
203+ compareString (h1 .toPDB (), h2 .toPDB ());
218204 }
205+ assertEquals ("the PDBHeader.toPDB representation is not equivalent" , h1 .toPDB ().toUpperCase (),h2 .toPDB ().toUpperCase ());
206+
207+ // and the ultimate test!
208+ // but we are not there yet...
209+ // TODO: still need to parse SSBOND equivalent info from cif files...
210+ //assertEquals("the Structure.toPDB representation is not equivalent", pdbStructure.toPDB(),cifStructure.toPDB());
211+
212+
219213
220214 }
221215
0 commit comments