Skip to content

Cannot parse pdb file.  #702

Closed
Closed

Description

@jendelel

Hi,

it seems that I cannot parse any pdb file using PDBFileReader.
This simple code fails for me (2src_off.pdb is official 2src PDB file from RCSB):

    PDBFileReader pdbReader = new PDBFileReader();
    //pdbReader.getFileParsingParameters().setCreateAtomCharges(false);
    String path = "~/pranklib/2src_off.pdb";
    Structure structure = null;
    try {
      structure = pdbReader.getStructure(path);
      System.out.println(structure);
    } catch (IOException e) {
      e.printStackTrace();
    } 

with error:

20:22:57 [main] ERROR org.biojava.nbio.structure.io.mmcif.SimpleMMcifParser - This does not look like a valid mmCIF file! The first line should start with 'data_', but is: 'null'
Exception in thread "main" java.lang.NullPointerException
        at org.biojava.nbio.structure.io.ChargeAdder.addCharges(ChargeAdder.java:55)
        at org.biojava.nbio.structure.io.PDBFileParser.addCharges(PDBFileParser.java:2772)
        at org.biojava.nbio.structure.io.PDBFileParser.parsePDBFile(PDBFileParser.java:2760)
        at org.biojava.nbio.structure.io.PDBFileParser.parsePDBFile(PDBFileParser.java:2622)
        at org.biojava.nbio.structure.io.PDBFileReader.getStructure(PDBFileReader.java:307)
        at org.biojava.nbio.structure.io.LocalPDBDirectory.getStructure(LocalPDBDirectory.java:337)
        at org.biojava.nbio.structure.io.LocalPDBDirectory.getStructure(LocalPDBDirectory.java:321)
        at hello.HelloWorld.main(HelloWorld.java:22)

Weird thing is that it didn't fail before. How is that possible? Also we do I get so many ERROR from MMcifParser when I am parsing PDB and not mmCIF?

Thanks in advance for any help.

Lukas

Activity

  1. josemduarte commented on Aug 30, 2017

    @josemduarte
    Contributor

    This works for me with latest HEAD:

    package org.biojava.nbio.structure;
    
    import org.biojava.nbio.structure.io.PDBFileReader;
    import org.junit.Test;
    import static org.junit.Assert.*;
    
    public class TestParserIssue702 {
    	
    	@Test
    	public void testParser() throws Exception {
    
    		PDBFileReader pdbReader = new PDBFileReader();
    		pdbReader.getFileParsingParameters().setCreateAtomCharges(false);
    		String path = "~/2src.pdb";
    		Structure structure = null;
    
    		structure = pdbReader.getStructure(path);
    		System.out.println(structure);
    		assertNotNull(structure);
    
    	}
    
    }

    With output:

    structure  2SRC JournalArticle: JRNL        AUTH   W.XU,A.DOSHI,M.LEI,M.J.ECK,S.C.HARRISON,
    JRNL        TITL   CRYSTAL STRUCTURES OF C-SRC REVEAL FEATURES OF ITS AUTOINHIBITORY MECHANISM.
    JRNL        REF    MOL.CELL                      V.   3   629 1999 
    JRNL        REFN                   ISSN 1097-2765
    JRNL        PMID   10360179
    JRNL        DOI    10.1016/S1097-2765(00)80356-1
     CrystallographicInfo: [P 21 21 21 - 50.59 72.97 172.69, 90.00 90.00 90.00] ExperimentalTechniques: [X-RAY DIFFRACTION] Classification: TYROSINE-PROTEIN KINASE IdCode: 2SRC Rfree: 0.281 RelDate: Thu Jul 22 00:00:00 PDT 1999 BioAssemblies: {} NrBioAssemblies: 0 Rwork: 1.0 Authors: W.XU,A.DOSHI,M.LEI,M.J.ECK,S.C.HARRISON ModDate: Tue Feb 24 00:00:00 PST 2009 Title: CRYSTAL STRUCTURE OF HUMAN TYROSINE-PROTEIN KINASE C-SRC, IN COMPLEX WITH AMP-PNP Resolution: 1.5 DepDate: Tue Dec 29 00:00:00 PST 1998 
     chains:
    chain 0: asymId:A authId:A TYROSINE-PROTEIN KINASE SRC (POLYMER)
     length SEQRES: 452 length ATOM: 450 aminos: 450 hetatms: 0 nucleotides: 0
    chain 1: asymId:B authId:A ANP (NONPOLYMER)
     length SEQRES: 0 length ATOM: 1 aminos: 0 hetatms: 1 nucleotides: 0
    chain 2: asymId:C authId:A water (WATER)
     length SEQRES: 0 length ATOM: 269 aminos: 0 hetatms: 269 nucleotides: 0
    DBRefs: 1
    DBREF  2SRC A   83   533  UNP    P12931   SRC_HUMAN       85    535             
    Molecules: 
    EntityInfo: 1 (TYROSINE-PROTEIN KINASE SRC) asymIds: A
    EntityInfo: 2 (ANP) asymIds: B
    EntityInfo: 3 (water) asymIds: C
    
    

    That's using the official 2src.pdb as downloaded from RCSB. How's your environment? are you using maven? what version of biojava?

  2. jendelel commented on Aug 30, 2017

    @jendelel
    Author

    I used gradle and version 4.2.8, I also tried 4.2.6 and 4.2.4.

    However, you setCreateAtomCharges(false). If it's true, it doesn't work. Why?

  3. josemduarte commented on Aug 30, 2017

    @josemduarte
    Contributor

    I've just tried with 4.2.8 and everything works fine too. It works fine with either true or false in setCreateAtomCharges() (or even with the line commented out).

    Is your file exactly like the original provided by PDB? Can you try downloading it again in case the latest remediations have changed it?

    As a note, the best and most reliable way to get structure information in biojava is to use the mmCIF files. In fact if all you want is reading deposited PDB structures you can use the AtomCache feature:

    	AtomCache cache = new AtomCache();
    	StructureIO.setAtomCache(cache);
    	Structure sCif = StructureIO.getStructure("2SRC");

    See https://github.com/biojava/biojava-tutorial/blob/master/structure/caching.md for more info

  4. jendelel commented on Aug 30, 2017

    @jendelel
    Author

    I don't know what I am doing wrong then. Are you using gradle or maven?

    Can you send me zipped directory with your test in it please. I will try to run it on my PC. It that one works, I will look for difference.

    It must be something stupid because it worked for my until now.

    Thank you for your help,

    Lukas

  5. jendelel commented on Aug 30, 2017

    @jendelel
    Author

    And yes, I used the latest pdb file from rcsb.

  6. josemduarte commented on Aug 30, 2017

    @josemduarte
    Contributor

    One more hint: the parser also downloads (and caches locally) cif files for each ligand. Could you try to remove all of those cached locally (set in PDB_DIR or PDB_CACHE_DIR) and try again? That could explain why you see a problem in the cif parser in your stack trace.

  7. jendelel commented on Aug 30, 2017

    @jendelel
    Author

    I don't have any of these set, but I removed chemcomp from /tmp. Unfortunately it didn't help. Any ideas why I am getting so many ERROR logs from SimpleMMcifParser? It shouldn't use the class at all right?

  8. josemduarte commented on Aug 30, 2017

    @josemduarte
    Contributor

    why I am getting so many ERROR logs from SimpleMMcifParser? It shouldn't use the class at all right?

    It does to parse the chemical component dictionary files (for each ligand or aminoacid).

    Also be sure you are using 4.2.8, the location of the chemical component files changed in the RCSB servers and 4.2.8 was patched accordingly to point to the new location.

  9. jendelel commented on Aug 31, 2017

    @jendelel
    Author

    Can you please take a look at these to small examples?
    maven
    gradle

    This is the file I tried 2src

    They both the same way for me and I have no idea why...

    Thank you so much,
    Lukas

    Lukas

  10. jendelel commented on Aug 31, 2017

    @jendelel
    Author

    I also tried these commands and the tests failed:

    git clone https://github.com/biojava/biojava.git
    cd biojava/
    mvn package

    Any ideas why is that happening?

    Thank you,
    Lukas

  11. josemduarte commented on Aug 31, 2017

    @josemduarte
    Contributor

    Can you be more specific, what tests fail? maven should give quite specific reports about which tests fail

  12. jendelel commented on Aug 31, 2017

    @jendelel
    Author

    Here is a complete log of stdout and stderr from the mvn package commnad.

  13. jendelel commented on Aug 31, 2017

    @jendelel
    Author

    Excerpt from the logs:

    Results :
    
    Failed tests: 
      FastaAFPChainConverterTest.testFromFasta:173 AFPChain is wrong
      TestChemCompProvider.testZipChemCompProvider:141 expected:<3> but was:<1>
    Tests in error: 
      ChemCompTest.testALA:42 NullPointer
      SourceCompoundTest.testCOMPNDsectionCHAINS:114->getStructure:43 » NullPointer
      SourceCompoundTest.testCOMPNDsectionFRAGMENT:92->getStructure:43 » NullPointer
      SourceCompoundTest.testCompoundSourceStructure:53->getStructure:43 » NullPointer
      SourceCompoundTest.testJournalRefs:202->getStructure:43 » NullPointer
      SourceCompoundTest.testSOURCEsectionORGSCI:165->getStructure:43 » NullPointer
      SourceCompoundTest.testSOURCEsectionSTRAIN:129->getStructure:43 » NullPointer
      SourceCompoundTest.testSourceTaxIdVersion32File:181->getStructure:43 » NullPointer
      Test2JA5.test2JA5:49 » NullPointer
      Test4hhb.test4hhbPDBFile:63 » NullPointer
      TestAltLocs.test1AAC:211 » NullPointer
      TestAltLocs.test3PIUmmcif:502 » NullPointer
      TestAltLocs.test3PIUpdb:275 » NullPointer
      TestAltLocs.test3U7Tmmcif:567 » NullPointer
      TestAltLocs.test4CUPBonds:441 » NullPointer
      TestAltLocs.testAddBondsDoesntChangeGroups:403 NullPointer
      TestAltLocs.testAltLocParsing:45 » NullPointer
      TestAtomCache.testFetchCurrent1HHB:192 » NullPointer
      TestAtomCache.testFetchObsolete:209 » NullPointer
      TestBond.test145D:281 » NullPointer
      TestBond.test1APJ:286 » NullPointer
      TestBond.test1BDX:291 » NullPointer
      TestBond.testAltLocBondMissing:196->testMissingBonds:205 » NullPointer
      TestBond.testDeuterated:302->testMissingBonds:205 » NullPointer
      TestBond.testDisulfideBonds:110 » NullPointer
      TestBond.testHeavyAtomBondMissing:168->testMissingBonds:205 » NullPointer
      TestBond.testHydrogenToProteinBondMissing:185->testMissingBonds:205 » NullPointer
      TestBond.testIntraResidueBonds:70 » NullPointer
      TestBond.testLigandBonds:121 » NullPointer
      TestBond.testNucleotideBonds:136 » NullPointer
      TestBond.testPeptideBonds:95 » NullPointer
      TestBond.testSSBonds:328->testBondedToSelf:234 » NullPointer
      TestBond.testStructConnModels:58 » NullPointer
      TestBond.testWeirdCase:316->testMissingBonds:205 » NullPointer
      TestChargeAdder.testBasic:28 » NullPointer
      TestChargeAdder.testQuestionMark:54 » NullPointer
      TestCompoundResIndexMapping.test1B8G:51 » NullPointer
      TestCompoundResIndexMapping.test1SMT:74 » NullPointer
      TestCompoundResIndexMapping.test3ddoRawSeqres:172->getStructure:217 » NullPointer
      TestEntityHeuristics.test1b8gRaw:54->getStructure:241 » NullPointer
      TestEntityHeuristics.test2m7yRaw:86->getStructure:241 » NullPointer
      TestEntityHeuristics.test3c5fRaw:117->getStructure:241 » NullPointer
      TestEntityHeuristics.test3ddoNoseqres:191->getStructure:241 » NullPointer
      TestEntityHeuristics.test3ddoSeqres:214->getStructure:241 » NullPointer
      TestEntityHeuristics.test4b19Raw:158->getStructure:241 » NullPointer
      TestExperimentalTechniques.test2B6O:103 » NullPointer
      TestExperimentalTechniques.test3ZPK:73 » NullPointer
      TestExperimentalTechniques.test4CSO:133 » NullPointer
      TestExperimentalTechniques.test4LNC:43 » NullPointer
      TestLoadStructureFromURL.testLoadStructureFromURL:57 » NullPointer
      TestNucleotides.test1REP:151 » NullPointer
      TestNucleotides.test3T5N:87 » NullPointer
      TestParsingCalcium.testCalciumParsing:51 » NullPointer
      TestStructureCrossReferences.testCrossReferencesMmCif:61 » NullPointer
      TestStructureCrossReferences.testCrossReferencesMmCifAlignSeqRes:84 » NullPointer
      TestStructureCrossReferences.testCrossReferencesPdb:108 » NullPointer
      TestStructureCrossReferences.testCrossReferencesPdbAlignSeqRes:131 » NullPointer
      TestStructureSerialization.testSerializeStructure:47 » NullPointer
      TestURLIdentifier.testFileIdentifiers:48 » NullPointer
      TestURLIdentifier.testURLParameters:80 » NullPointer
      TestSmallAlignment.test1a4w:62 » NumberFormat For input string: "0,00"
      TestMultipleAlignmentWriter.<init>:62 » NullPointer
      TestMultipleAlignmentWriter.<init>:62 » NullPointer
      TestMultipleAlignmentWriter.<init>:62 » NullPointer
      TestMultipleAlignmentWriter.<init>:62 » NullPointer
      TestMultipleAlignmentWriter.<init>:62 » NullPointer
      TestMultipleAlignmentWriter.<init>:62 » NullPointer
      TestMultipleAlignmentXMLParser.testRecovery1:59 » NullPointer
      AtomCacheTest.testFetchBehavior:201 » NullPointer
      TestDifficultMmCIFFiles.test1GQO:140 » NullPointer
      TestDifficultMmCIFFiles.test2BI6:111 » NullPointer
      TestDifficultMmCIFFiles.test2KLI:264 » NullPointer
      TestDifficultMmCIFFiles.test2KSA:83 » NullPointer
      TestDifficultMmCIFFiles.test4letterChains:197 » NullPointer
      TestDifficultMmCIFFiles.testResidueNumbers:175 » NullPointer
      TestHardBioUnits.test4A1Immcif:63 » NullPointer
      TestHeaderOnly.testAlignSeqres:109 » NullPointer
      TestMMCIFWriting.test1A2C:68->testRoundTrip:122 » NullPointer
      TestMMCIFWriting.test1SMT:51->testRoundTrip:122 » NullPointer
      TestMMCIFWriting.test2N3J:62->testRoundTrip:122 » NullPointer
      TestMMcifOrganismParsing.test1STP:59->checkPDB:90 » NullPointer
      TestMMcifOrganismParsing.test3ZD6:84->checkPDB:90 » NullPointer
      TestMMcifOrganismParsing.test4hhb:75->checkPDB:90 » NullPointer
      TestNonDepositedFiles.test1B8GnoSeqresPdb:68 » NullPointer
      TestNonDepositedFiles.test2M7Y:177 » NullPointer
      TestNonDepositedFiles.test3C5F:137 » NullPointer
      TestNonDepositedFiles.test4B19:157 » NullPointer
      TestNonDepositedFiles.testNewLigandChain:333 » NullPointer
      TestNonDepositedFiles.testPhaserPdbFile:273 » NullPointer
      TestNonDepositedFiles.testPhenixCifFile:216 » NullPointer
      TestNonDepositedFiles.testPhenixPdbFile:246 » NullPointer
      TestNonDepositedFiles.testRefmacPdbFile:294 » NullPointer
      TestNonDepositedFiles.testWaterOnlyChainCif:390 » NullPointer
      TestNonDepositedFiles.testWaterOnlyChainPdb:365 » NullPointer
      TestParseMmCIFFeatures.testSSBond:52 » NullPointer
      TestParseMmCIFFeatures.testSSBondAltLocs:84 » NullPointer
      TestParseMmCIFFeatures.testSites:151 » NullPointer
      TestParseMmCIFFeatures.testSites1a4w:185 » NullPointer
      TestParseMmCIFLigands.testLigandConnections:63 » NullPointer
      TestParseMmCIFLigands.testMultipleConformations:106 » NullPointer
      TestParseOnAsymId.test4cup:53 » NullPointer
      TestQuaternaryStructureProviders.test1A29:92->comparePdbVsMmcif:119->getPdbBioAssembly:203 » NullPointer
      TestQuaternaryStructureProviders.test1EI7:98->comparePdbVsMmcif:119->getPdbBioAssembly:203 » NullPointer
      TestQuaternaryStructureProviders.test1STP:41->comparePdbVsMmcif:119->getPdbBioAssembly:203 » NullPointer
      TestQuaternaryStructureProviders.test3FAD:46->comparePdbVsMmcif:119->getPdbBioAssembly:203 » NullPointer
      TestQuaternaryStructureProviders.test3NTU:87->comparePdbVsMmcif:119->getPdbBioAssembly:203 » NullPointer
      TestQuaternaryStructureProviders.test5LDH:52->comparePdbVsMmcif:119->getPdbBioAssembly:203 » NullPointer
      TestQuaternaryStructureProviders.testGetNrBioAssemblies5LDH:104 » NullPointer
      TestTitleParsing.test2W6E:52 » NullPointer
      TestURLBasedFileParsing.testMMcifURL:42 » NullPointer
      TestWriteLargeCoordinatePDB.TestWrite5D9Q:33 » NullPointer
      TestEntityNameAndType.testEntityId:49 » NullPointer
      TestMmcifV5Changes.setup:33 » NullPointer
      TestMmcifV5Changes.setup:33 » NullPointer
      TestMmcifV5Changes.setup:33 » NullPointer
      TestParseInternalChainId.test2I13:26 » NullPointer
      TestParseMmcifHeader.testDatesV4:53 » NullPointer
      TestParseMmcifHeader.testDatesV5:76 » NullPointer
      TestParseMmcifHeader.testRfactors:36 » NullPointer
      TestBondFinding.testInterGroupBonds:37->getInterBonds:69 » NullPointer
      TestMmtfPerformance.test3HBX:126 » NullPointer
      TestMmtfRoundTrip.testRoundTrip:45 » NullPointer
      TestMmtfUtils.microHeterogenity:56 » NullPointer
      TestDSSPParser.testDSSPParser:66 » NumberFormat For input string: "360,0"
      TestCrystalInfo.test1B8G:73 » NullPointer
      TestCrystalInfo.test1NMR:49 » NullPointer
      TestCrystalInfo.test2MBQ:127 » NullPointer
      TestCrystalInfo.test4M7P:99 » NullPointer
      TestInterfaceClustering.test3C5FWithSeqresPdb:97 » NullPointer
      TestInterfaceClustering.test3DDO:55 » NullPointer
    
    Tests run: 330, Failures: 2, Errors: 130, Skipped: 1
    
  14. josemduarte commented on Aug 31, 2017

    @josemduarte
    Contributor

    It seems you do get the same problem in all tests: the chemical component <ligand 3 letter code>.cif files are not getting parsed. Could you check 2 things:

  15. jendelel commented on Aug 31, 2017

    @jendelel
    Author

    This is my chemcomp directory in /tmp:
    http://www.ms.mff.cuni.cz/~jendelel/chemcomp.zip

  16. josemduarte commented on Aug 31, 2017

    @josemduarte
    Contributor

    The dir contents look quite alright and it seems to indicate that you can download the chem comp files. This is very weird. Could you try to run your example through a debugger to get some better idea on why the files can't be parsed? It seems that the parser can't even go through the first line (should contain data_...), instead the parser is getting a null for some reason.

    What's your Operating System? and java version?

  17. josemduarte commented on Aug 31, 2017

    @josemduarte
    Contributor

    By the way I've tried downloading and running your code (maven version) and it all works fine. So definitely this has to do with the environment and not with the code.

  18. jendelel commented on Sep 1, 2017

    @jendelel
    Author

    I run it on Linux, some kind of Debian system.

    $ java -version                                                    [7:59:42]
    java version "1.8.0_144"
    Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
    Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

    I agree that it is something with the Environment because it worked and I didn't do any code changes.
    I will try to run it on Windows. I will also try to set the PDB_CACHE_DIR. Is there any other environment settings?

    Thanks for your help.

    Lukas

  19. sbliven commented on Sep 2, 2017

    @sbliven
    Member

    The problem is that you have a bunch of empty chemical compound files in your chemcomp directory. For instance, ALA.cif.gz is only 20 bytes (just the gzip header).

    The work around is easy: just delete the chemcomp folder and you should be good.

    I also had a bunch of these empty gz files. I think they probably happen if you try to use a version of biojava with the old RCSB urls (e.g. 4.2.7; anything missing dc7f3ea). The faulty URL gets cached and then fails even with recent code.

    Although the work around is easy, we could also handle this case in BioJava by re-downloading files with size 20B (I think this already happens for size 0 files, but we didn't consider the gzip header).

    As a separate issue, I dislike that errors in fetching chemical compounds break parsing. It means we require an internet connection even for local files unless you do the unusual step of specifically switching to a ReducedChemCompProvider.

  20. sbliven commented on Sep 2, 2017

    @sbliven
    Member

    I confirmed that using old tools, e.g. the current CE-Symm 2.0.0-RC2, will download empty chemical compounds.

  21. josemduarte commented on Sep 2, 2017

    @josemduarte
    Contributor

    There's a couple of fixes to implement:

    • do not store files if the download is empty or any kind of server error (404 or others)
    • better error handling when the file doesn't have valid content, trying a redownload
  22. jendelel commented on Sep 2, 2017

    @jendelel
    Author

    Yes, clearing the cache dir and updating to version 4.2.8 solved the issue for me. As for the fixes, I totally agree. Shall I close the issue or will you close when the fixes are implemented?

    Thank you guys for your help.

  23. josemduarte commented on Sep 2, 2017

    @josemduarte
    Contributor

    I've added a new issue. Will close this one, thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions