Skip to content

Commit 15c0ad1

Browse files
authored
Merge pull request #735 from josemduarte/cryst1ParsingIssue
Fix for CRYST1 parsing issue
2 parents 4680fd8 + 2fdeb6c commit 15c0ad1

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

‎biojava-structure/src/main/java/org/biojava/nbio/structure/io/PDBFileParser.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,9 +1468,9 @@ private void pdb_EXPDTA_Handler(String line) {
14681468
* </pre>
14691469
*/
14701470
private void pdb_CRYST1_Handler(String line) {
1471-
// for badly formatted files (e.g. phenix-produced ones), there's no z and the min length is 63
1472-
if (line.length() < 63) {
1473-
logger.warn("CRYST1 record has fewer than 63 columns: will ignore it");
1471+
// for badly formatted files (e.g. phenix-produced ones), there's no z and the min length is 58 (e.g. for SG 'P 1')
1472+
if (line.length() < 58) {
1473+
logger.warn("CRYST1 record has fewer than 58 columns: will ignore it");
14741474
return;
14751475
}
14761476

‎biojava-structure/src/test/java/org/biojava/nbio/structure/io/TestNonDepositedFiles.java‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import static org.junit.Assert.*;
2424

2525
import java.io.BufferedReader;
26+
import java.io.ByteArrayInputStream;
2627
import java.io.IOException;
2728
import java.io.InputStream;
2829
import java.io.InputStreamReader;
@@ -408,6 +409,23 @@ public void testWaterOnlyChainCif() throws IOException {
408409
assertSame(c, cAsymId);
409410

410411
}
412+
413+
/**
414+
* Some PDB files coming from phenix or other software can have a CRYST1 line without z and not padded with white-spaces
415+
* for the space group column.
416+
* @throws IOException
417+
* @since 5.0.0
418+
*/
419+
@Test
420+
public void testCryst1Parsing() throws IOException {
421+
String cryst1Line = "CRYST1 11.111 11.111 111.111 70.00 80.00 60.00 P 1";
422+
Structure s;
423+
PDBFileParser pdbPars = new PDBFileParser();
424+
try(InputStream is = new ByteArrayInputStream(cryst1Line.getBytes()) ) {
425+
s = pdbPars.parsePDBFile(is);
426+
}
427+
assertEquals("P 1", s.getPDBHeader().getCrystallographicInfo().getSpaceGroup().getShortSymbol());
428+
}
411429

412430

413431
private static int[] countEntityTypes(List<EntityInfo> entities) {

0 commit comments

Comments
 (0)