Skip to content

Commit 8bb0b4e

Browse files
committed
Parse the release date from PDB files
1 parent e60c671 commit 8bb0b4e

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
import org.slf4j.LoggerFactory;
8282

8383

84-
8584
/**
8685
* This class implements the actual PDB file parsing. Do not access it directly, but
8786
* via the PDBFileReader class.
@@ -673,11 +672,24 @@ private void pdb_TURN_Handler( String line){
673672
*/
674673
private void pdb_REVDAT_Handler(String line) {
675674

676-
// only keep the first...
677-
Date modDate = pdbHeader.getModDate();
675+
// keep the first as release date and the last as modification date
676+
Date relDate = pdbHeader.getRelDate();
677+
678+
if ( relDate == null || relDate.equals(new Date(0)) ) {
679+
680+
// release date is still uninitialized
681+
String releaseDate = line.substring (13, 22).trim() ;
682+
683+
try {
684+
Date dep = dateFormat.parse(releaseDate);
685+
pdbHeader.setModDate(dep);
686+
} catch (ParseException e){
687+
logger.info("Could not parse modification date string '"+releaseDate+"'. Will continue without modification date");
688+
}
678689

679-
if ( modDate==null || modDate.equals(new Date(0)) ) {
680-
// modDate is still uninitialized
690+
} else {
691+
692+
// set as the latest modification date
681693
String modificationDate = line.substring (13, 22).trim() ;
682694

683695
try {
@@ -686,7 +698,6 @@ private void pdb_REVDAT_Handler(String line) {
686698
} catch (ParseException e){
687699
logger.info("Could not parse modification date string '"+modificationDate+"'. Will continue without modification date");
688700
}
689-
690701
}
691702
}
692703

0 commit comments

Comments
 (0)