Skip to content

Commit dbdc477

Browse files
authored
Merge pull request biojava#680 from lafita/mmcif5
Add the release date to PDBHeader
2 parents ee3a2d4 + 28a8ff3 commit dbdc477

File tree

11 files changed

+4500
-60
lines changed

11 files changed

+4500
-60
lines changed

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/PDBFileParserTest.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import java.io.IOException;
3333
import java.io.InputStream;
3434
import java.io.StringReader;
35-
3635
import org.biojava.nbio.structure.Atom;
3736
import org.biojava.nbio.structure.Chain;
3837
import org.biojava.nbio.structure.ChainImpl;
@@ -50,6 +49,12 @@
5049
import org.junit.Before;
5150
import org.junit.Test;
5251

52+
/**
53+
* Test the {@link PDBFileParser}.
54+
*
55+
* @author Aleix Lafita
56+
*
57+
*/
5358
public class PDBFileParserTest {
5459

5560
private static PDBFileParser parser;
@@ -555,8 +560,6 @@ public void testCorrectAtomNamePadding() throws IOException {
555560

556561
/**
557562
* Test handling of missing Element column. Issue 537 in github.
558-
* @author Aleix Lafita
559-
* @throws IOException
560563
*/
561564
@Test
562565
public void testMissingElements() throws IOException {
@@ -627,4 +630,28 @@ public void testMissingElements() throws IOException {
627630
assertTrue("the Element column has not been filled correctly", pdb.equals(original));
628631

629632
}
633+
634+
/**
635+
* Test the parsing of release and last modified dates.
636+
*/
637+
@Test
638+
public void testDates() throws IOException {
639+
640+
String revisionDates =
641+
"REVDAT 5 13-JUL-11 1STP 1 VERSN "+newline+
642+
"REVDAT 4 24-FEB-09 1STP 1 VERSN " + newline+
643+
"REVDAT 3 01-APR-03 1STP 1 JRNL " + newline+
644+
"REVDAT 2 15-OCT-94 1STP 1 AUTHOR " + newline+
645+
"REVDAT 1 15-OCT-92 1STP 0 " + newline;
646+
647+
BufferedReader br = new BufferedReader(new StringReader(revisionDates));
648+
Structure s = parser.parsePDBFile(br);
649+
650+
// The latest modified date should be 2011
651+
assertEquals(s.getPDBHeader().getModDate().getYear() + 1900, 2011);
652+
653+
// The release date should be 1992
654+
assertEquals(s.getPDBHeader().getRelDate().getYear() + 1900, 1992);
655+
656+
}
630657
}

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/io/StructureIOTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
*/
2121
package org.biojava.nbio.structure.test.io;
2222

23-
2423
import static org.junit.Assert.*;
2524

2625
import java.io.IOException;
@@ -29,15 +28,16 @@
2928
import org.biojava.nbio.structure.StructureIO;
3029
import org.junit.Test;
3130

32-
33-
31+
/**
32+
* Test StructureIO methods.
33+
*
34+
*/
3435
public class StructureIOTest {
3536

3637
@Test
3738
public void testStructureIO() throws IOException, StructureException {
3839

3940
String pdbId = "1gav";
40-
4141
int nrAssembls = StructureIO.getBiologicalAssemblies(pdbId).size();
4242
assertEquals(1,nrAssembls);
4343

biojava-structure/src/main/java/org/biojava/nbio/structure/PDBHeader.java

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
import java.util.*;
3636

3737

38-
/** A class that contains PDB Header information.
38+
/**
39+
* A class that contains PDB Header information.
3940
*
4041
* @author Andreas Prlic
4142
* @since 1.6
@@ -53,15 +54,14 @@ public class PDBHeader implements PDBRecord {
5354
private String classification;
5455

5556
private Date depDate;
57+
private Date relDate;
5658
private Date modDate;
5759

5860
private Set<ExperimentalTechnique> techniques;
5961
private PDBCrystallographicInfo crystallographicInfo;
6062

6163
private float resolution;
62-
6364
private float rFree;
64-
6565
private float rWork;
6666

6767
private JournalArticle journalArticle;
@@ -84,10 +84,13 @@ public PDBHeader(){
8484

8585
depDate = new Date(0);
8686
modDate = new Date(0);
87+
relDate = new Date(0);
8788
dateFormat = new SimpleDateFormat("dd-MMM-yy",Locale.US);
89+
8890
resolution = DEFAULT_RESOLUTION;
8991
rFree = DEFAULT_RFREE;
9092
rWork = DEFAULT_RFREE;
93+
9194
bioAssemblies = new HashMap<Integer, BioAssemblyInfo>();
9295
crystallographicInfo = new PDBCrystallographicInfo();
9396

@@ -471,10 +474,20 @@ public void setClassification(String classification) {
471474
this.classification = classification;
472475
}
473476

477+
/**
478+
* Return the deposition date of the structure in the PDB.
479+
*
480+
* @return the deposition date
481+
*/
474482
public Date getDepDate() {
475483
return depDate;
476484
}
477485

486+
/**
487+
* The deposition date of the structure in the PDB
488+
*
489+
* @param depDate the deposition date
490+
*/
478491
public void setDepDate(Date depDate) {
479492
this.depDate = depDate;
480493
}
@@ -535,13 +548,42 @@ public void setRfree(float rFree) {
535548
this.rFree = rFree;
536549
}
537550

551+
/**
552+
* Return the latest modification date of the structure.
553+
*
554+
* @return the latest modification date
555+
*/
538556
public Date getModDate() {
539557
return modDate;
540558
}
541559

560+
/**
561+
* The latest modification date of the structure.
562+
*
563+
* @param modDate the latest modification date
564+
*/
542565
public void setModDate(Date modDate) {
543566
this.modDate = modDate;
544567
}
568+
569+
/**
570+
* Return the release date of the structure in the PDB.
571+
*
572+
* @return the release date
573+
*/
574+
public Date getRelDate() {
575+
return relDate;
576+
}
577+
578+
/**
579+
*
580+
* The release date of the structure in the PDB.
581+
*
582+
* @param relDate the release date
583+
*/
584+
public void setRelDate(Date relDate) {
585+
this.relDate = relDate;
586+
}
545587

546588
public String getTitle() {
547589
return title;

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

Lines changed: 17 additions & 5 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,20 +672,33 @@ private void pdb_TURN_Handler( String line){
673672
*/
674673
private void pdb_REVDAT_Handler(String line) {
675674

676-
// only keep the first...
675+
// keep the first as latest modified date and the last as release date
677676
Date modDate = pdbHeader.getModDate();
678677

679-
if ( modDate==null || modDate.equals(new Date(0)) ) {
680-
// modDate is still uninitialized
678+
if ( modDate == null || modDate.equals(new Date(0)) ) {
679+
680+
// modified date is still uninitialized
681681
String modificationDate = line.substring (13, 22).trim() ;
682682

683683
try {
684684
Date dep = dateFormat.parse(modificationDate);
685685
pdbHeader.setModDate(dep);
686+
pdbHeader.setRelDate(dep);
686687
} catch (ParseException e){
687-
logger.info("Could not parse modification date string '"+modificationDate+"'. Will continue without modification date");
688+
logger.info("Could not parse revision date string '"+modificationDate+"'. ");
688689
}
689690

691+
} else {
692+
693+
// set as the release date
694+
String releaseDate = line.substring (13, 22).trim() ;
695+
696+
try {
697+
Date dep = dateFormat.parse(releaseDate);
698+
pdbHeader.setRelDate(dep);
699+
} catch (ParseException e){
700+
logger.info("Could not parse revision date string '"+releaseDate+"'. ");
701+
}
690702
}
691703
}
692704

biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/SimpleMMcifConsumer.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,15 +1371,16 @@ public void newDatabasePDBrevRecord(DatabasePdbrevRecord record) {
13711371

13721372
@Override
13731373
public void newDatabasePDBrev(DatabasePDBrev dbrev) {
1374-
//System.out.println("got a database revision:" + dbrev);
1374+
1375+
logger.debug("got a database revision:" + dbrev);
1376+
13751377
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd",Locale.US);
13761378
PDBHeader header = structure.getPDBHeader();
13771379

13781380
if ( header == null) {
13791381
header = new PDBHeader();
13801382
}
13811383

1382-
13831384
if (dbrev.getNum().equals("1")){
13841385

13851386
try {
@@ -1391,8 +1392,8 @@ public void newDatabasePDBrev(DatabasePDBrev dbrev) {
13911392
}
13921393

13931394
try {
1394-
Date mod = dateFormat.parse(dbrev.getDate());
1395-
header.setModDate(mod);
1395+
Date rel = dateFormat.parse(dbrev.getDate());
1396+
header.setRelDate(rel);
13961397

13971398
} catch (ParseException e){
13981399
logger.warn("Could not parse date string '{}', modification date will be unavailable", dbrev.getDate());

biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/SimpleMMcifParser.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,15 @@ private void endLineChecks(String category,List<String> loopFields, List<String>
647647
loopFields, lineData, loopWarnings);
648648

649649
triggerNewDatabasePDBrevRecord(dbrev);
650+
651+
// MMCIF version 5 dates
652+
} else if ( category.equals("_pdbx_database_status")){
653+
// TODO
650654

655+
// MMCIF version 5 dates
656+
} else if ( category.equals("_pdbx_audit_revision_history")){
657+
// TODO
658+
651659
}else if ( category.equals("_database_PDB_remark")){
652660
DatabasePDBremark remark = (DatabasePDBremark) buildObject(
653661
DatabasePDBremark.class.getName(),

biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf/MmtfStructureWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public MmtfStructureWriter(Structure structure, StructureAdapterInterface dataTr
5353
PDBHeader pdbHeader = structure.getPDBHeader();
5454
PDBCrystallographicInfo xtalInfo = pdbHeader.getCrystallographicInfo();
5555
mmtfDecoderInterface.setHeaderInfo(pdbHeader.getRfree(), pdbHeader.getRwork(), pdbHeader.getResolution(), pdbHeader.getTitle(), MmtfUtils.dateToIsoString(pdbHeader.getDepDate()),
56-
MmtfUtils.dateToIsoString(pdbHeader.getModDate()), MmtfUtils.techniquesToStringArray(pdbHeader.getExperimentalTechniques()));
56+
MmtfUtils.dateToIsoString(pdbHeader.getRelDate()), MmtfUtils.techniquesToStringArray(pdbHeader.getExperimentalTechniques()));
5757
mmtfDecoderInterface.setXtalInfo(MmtfUtils.getSpaceGroupAsString(xtalInfo.getSpaceGroup()), MmtfUtils.getUnitCellAsArray(xtalInfo), MmtfUtils.getNcsAsArray(xtalInfo.getNcsOperators()));
5858
// Store the bioassembly data
5959
storeBioassemblyInformation(chainIdToIndexMap, pdbHeader.getBioAssemblies());

biojava-structure/src/test/java/org/biojava/nbio/structure/io/mmcif/TestParseHeader.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)