Skip to content

Commit 85b6c6b

Browse files
committed
chem comp parsing errors & missing crystal translation
1 parent 16792bd commit 85b6c6b

4 files changed

Lines changed: 22 additions & 29 deletions

File tree

biojava-structure/src/main/java/org/biojava/nbio/structure/chem/DownloadChemCompProvider.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.biojava.nbio.structure.align.util.UserConfiguration;
66
import org.biojava.nbio.structure.io.LocalPDBDirectory;
77
import org.biojava.nbio.structure.io.cif.ChemCompConverter;
8+
import org.rcsb.cif.ParsingException;
89
import org.slf4j.Logger;
910
import org.slf4j.LoggerFactory;
1011

@@ -217,8 +218,14 @@ public ChemComp getChemComp(String recordName) {
217218
if (haveFile) {
218219
String filename = getLocalFileName(recordName);
219220
try {
220-
ChemicalComponentDictionary dict = ChemCompConverter.fromPath(Paths.get(filename));
221-
ChemComp chemComp = dict.getChemComp(recordName);
221+
ChemComp chemComp;
222+
try {
223+
ChemicalComponentDictionary dict = ChemCompConverter.fromPath(Paths.get(filename));
224+
chemComp = dict.getChemComp(recordName);
225+
} catch (ParsingException e) {
226+
// happens for corrupt files
227+
chemComp = null;
228+
}
222229

223230
// May be null if the file was corrupt. Fall back on ReducedChemCompProvider in that case
224231
if (chemComp != null) {

biojava-structure/src/main/java/org/biojava/nbio/structure/io/cif/ChemCompConverter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.biojava.nbio.structure.io.cif;
22

3-
import org.biojava.nbio.structure.Structure;
43
import org.biojava.nbio.structure.chem.ChemicalComponentDictionary;
54
import org.biojava.nbio.structure.io.FileParsingParameters;
65
import org.rcsb.cif.CifIO;

biojava-structure/src/main/java/org/biojava/nbio/structure/io/cif/StructureConsumerImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,14 +1377,17 @@ private void setStructNcsOps() {
13771377
operator.setElement(0, 0, structNcsOper.getMatrix11().get(rowIndex));
13781378
operator.setElement(0, 1, structNcsOper.getMatrix12().get(rowIndex));
13791379
operator.setElement(0, 2, structNcsOper.getMatrix13().get(rowIndex));
1380+
operator.setElement(0, 3, structNcsOper.getVector1().get(rowIndex));
13801381

13811382
operator.setElement(1, 0, structNcsOper.getMatrix21().get(rowIndex));
13821383
operator.setElement(1, 1, structNcsOper.getMatrix22().get(rowIndex));
13831384
operator.setElement(1, 2, structNcsOper.getMatrix23().get(rowIndex));
1385+
operator.setElement(1, 3, structNcsOper.getVector2().get(rowIndex));
13841386

13851387
operator.setElement(2, 0, structNcsOper.getMatrix31().get(rowIndex));
13861388
operator.setElement(2, 1, structNcsOper.getMatrix32().get(rowIndex));
13871389
operator.setElement(2, 2, structNcsOper.getMatrix33().get(rowIndex));
1390+
operator.setElement(2, 3, structNcsOper.getVector3().get(rowIndex));
13881391

13891392
operator.setElement(3, 0, 0);
13901393
operator.setElement(3, 1, 0);

biojava-structure/src/test/java/org/biojava/nbio/structure/TestAtomCache.java

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -220,45 +220,32 @@ public void testFetchObsolete() throws IOException, StructureException {
220220

221221
}
222222

223-
224223
@Test
225224
public void testSettingFileParsingType(){
226-
227225
AtomCache cache = new AtomCache();
228226

229227
//test defaults
230-
231228
// first is mmtf, second is mmcif
232-
testFlags(cache,true,false);
229+
testFlags(cache, false, false, true);
233230

234231
// now change the values
235-
236232
cache.setFiletype(StructureFiletype.CIF);
237-
238-
testFlags(cache,false,true);
233+
testFlags(cache, false, true, false);
239234

240235
cache.setFiletype(StructureFiletype.MMTF);
241-
242-
testFlags(cache,true,false);
236+
testFlags(cache, true, false, false);
243237

244238
// this sets to use PDB!
245239
cache.setFiletype(StructureFiletype.PDB);
240+
testFlags(cache, false, false, false);
246241

247-
testFlags(cache,false,false);
248-
249-
// back to defaults
242+
// back to MMTF
250243
cache.setFiletype(StructureFiletype.MMTF);
251-
252-
testFlags(cache,true,false);
253-
244+
testFlags(cache, true, false, false);
254245

255246
// back to parsing PDB
256247
cache.setFiletype(StructureFiletype.PDB);
257-
258-
testFlags(cache,false,false);
259-
260-
261-
248+
testFlags(cache, false, false, false);
262249
}
263250

264251

@@ -268,15 +255,12 @@ public void testSettingFileParsingType(){
268255
* @param useMmTf
269256
* @param useMmCif
270257
*/
271-
private void testFlags(AtomCache cache ,boolean useMmTf, boolean useMmCif) {
272-
258+
private void testFlags(AtomCache cache ,boolean useMmTf, boolean useMmCif, boolean useBcif) {
273259
assertEquals("flag for parsing mmtf is set to " + cache.getFiletype() + " but should be " + useMmTf,
274260
cache.getFiletype() == StructureFiletype.MMTF, useMmTf);
275261
assertEquals("flag for parsing mmcif is set to " + cache.getFiletype() + " but should be set to " + useMmCif,
276262
cache.getFiletype() == StructureFiletype.CIF, useMmCif);
277-
278-
279-
263+
assertEquals("flag for parsing bcif is set to " + cache.getFiletype() + " but should be set to " + useBcif,
264+
cache.getFiletype() == StructureFiletype.BCIF, useBcif);
280265
}
281-
282266
}

0 commit comments

Comments
 (0)