[Biojava-dev] [Bug 3035] New: ParseException thrown when parsing PDB file.

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Fri Mar 26 06:14:17 UTC 2010


http://bugzilla.open-bio.org/show_bug.cgi?id=3035

           Summary: ParseException thrown when parsing PDB file.
           Product: BioJava
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: structure
        AssignedTo: biojava-dev at biojava.org
        ReportedBy: nakagawa-hiroyuki at mki.co.jp


When reading a PDB file using org.biojava.bio.structure.io.PDBFileReader on
non-English platform, java.text.ParseException is thrown.
java.text.ParseException: Unparseable date: "26-DEC-97"
        at java.text.DateFormat.parse(Unknown Source)
        at
org.biojava.bio.structure.io.PDBFileParser.pdb_HEADER_Handler(PDBFileParser.java:433)
        at
org.biojava.bio.structure.io.PDBFileParser.parsePDBFile(PDBFileParser.java:2067)
        at
org.biojava.bio.structure.io.PDBFileParser.parsePDBFile(PDBFileParser.java:1963)
        at
org.biojava.bio.structure.io.PDBFileReader.getStructure(PDBFileReader.java:486)
        at
org.biojava.bio.structure.io.PDBFileReader.getStructure(PDBFileReader.java:466)
        at Test.main(Test.java:9)

To reproduce this symptom, 
1.      Set your operating system’s default locale to non-English one(e.g.
Japanese).
2.      Then run the test code described below.
Or simply run the test code with the option “-Duser.language=ja”
> java -Duser.language=ja Test

----Begin Test.java ----
import org.biojava.bio.structure.io.PDBFileReader;
import org.biojava.bio.structure.Structure;
public class Test {
        public static void main(String[] args) {
                String filename =  "1a2b.pdb" ;
                PDBFileReader pdbreader = new PDBFileReader();
                try{
                        Structure structure = pdbreader.getStructure(filename);
                } catch (Exception e){
                        e.printStackTrace();
                }
        }
}
----End Test.java ----

This cause, that java.text.SimpleDateFormat can’t parse PDB style "dd-MMM-yy"
date format on some non-English locale.
I attached a patch to correct this problem.

---- Begin PDBFileParser.java.diff ----
*** .\biojava-1.7.1\src\org\biojava\bio\structure\io\PDBFileParser.java.orig   
2010-01-24 22:35:24.000000000 +0900
--- .\biojava-1.7.1\src\org\biojava\bio\structure\io\PDBFileParser.java
2010-03-19 11:34:28.571551900 +0900
***************
*** 271,277 ****
                current_compound = new Compound();
                dbrefs        = new ArrayList<DBRef>();

!               dateFormat = new SimpleDateFormat("dd-MMM-yy");
                atomCount = 0;
                atomOverflow = false;

--- 271,277 ----
                current_compound = new Compound();
                dbrefs        = new ArrayList<DBRef>();

!               dateFormat = new SimpleDateFormat("dd-MMM-yy",
java.util.Locale.ENGLISH);
                atomCount = 0;
                atomOverflow = false;

---- End PDBFileParser.java.diff ----


-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the biojava-dev mailing list