Skip to content

Commit 0913958

Browse files
committed
Moving KeyWords to PDBHeader
Updated the documentation Deprecated description
1 parent 76cf580 commit 0913958

File tree

9 files changed

+53
-43
lines changed

9 files changed

+53
-43
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ private static void testRoundTrip(String pdbId) throws IOException {
7272
assertEquals(originalStruct.nrModels(), readStruct.nrModels());
7373

7474
assertArrayEquals("Keywords Are not preserved",
75-
originalStruct.getKeywords().toArray(),
76-
readStruct.getKeywords().toArray());
75+
originalStruct.getPDBHeader().getKeywords().toArray(),
76+
readStruct.getPDBHeader().getKeywords().toArray());
7777

7878
for (int i = 0; i < originalStruct.nrModels(); i++) {
7979
assertEquals(originalStruct.getModel(i).size(), readStruct.getModel(i).size());

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

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@
3535

3636
/**
3737
* A class that contains PDB Header information.
38-
*
38+
* In contrast to what the name suggests, this class does not represent a
39+
* direct mapping of the Header section of the PDB legacy file format.
40+
* Instead, it holds the information that is not directly related to the
41+
* structure data. Such information may exist in some cases and may not exist in
42+
* other cases.
43+
*
3944
* @author Andreas Prlic
4045
* @since 1.6
4146
*
@@ -47,7 +52,10 @@ public class PDBHeader implements PDBRecord {
4752
private static final Logger logger = LoggerFactory.getLogger(PDBHeader.class);
4853

4954
private String title;
55+
/**@deprecated This field should not be used. It will be removed later.
56+
* Use {@link #getKeywords()} instead. */
5057
private String description;
58+
private List<String> keywords;
5159
private String idCode;
5260
private String classification;
5361

@@ -92,6 +100,8 @@ public PDBHeader(){
92100
bioAssemblies = new LinkedHashMap<Integer, BioAssemblyInfo>();
93101
crystallographicInfo = new PDBCrystallographicInfo();
94102

103+
keywords = new ArrayList<>();
104+
95105
}
96106

97107
/** String representation
@@ -589,9 +599,16 @@ public String getTitle() {
589599
public void setTitle(String title) {
590600
this.title = title;
591601
}
602+
603+
/**@deprecated will be removed later. Use {@link #getKeywords()}
604+
* @return
605+
*/
592606
public String getDescription() {
593607
return description;
594608
}
609+
/**@deprecated will be removed later. Use {@link #setKeywords(List)}
610+
* @param description
611+
*/
595612
public void setDescription(String description) {
596613
this.description = description;
597614
}
@@ -683,4 +700,22 @@ public float getRwork() {
683700
public void setRwork(float rWork) {
684701
this.rWork = rWork;
685702
}
703+
704+
/**
705+
* Gets the keywords (KEYWODS) record of the structure
706+
* @return The keywords in a <code>List&lt;String&gt;</code>
707+
* @since 6.0.0
708+
*/
709+
public List<String> getKeywords() {
710+
return keywords;
711+
}
712+
713+
/**
714+
* Sets the KEYWODS record of the structure.
715+
* @param keywords The keywords in a <code>List&lt;String&gt; to set.</code>
716+
* @since 6.0.0
717+
*/
718+
public void setKeywords(List<String> keywords) {
719+
this.keywords = keywords;
720+
}
686721
}

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

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,9 @@ public interface Structure extends Cloneable, Serializable {
665665
EntityInfo getEntityById(int entityId);
666666

667667
/**
668-
* Return the header information for this PDB file
668+
* Return the header information for this PDB file.
669+
* <b>N.B.</b> Take care when you blindly use the returned object from this method,
670+
* because it might be null in some cases.
669671
*
670672
* @return the PDBHeader object
671673
*/
@@ -789,17 +791,4 @@ public interface Structure extends Cloneable, Serializable {
789791
*/
790792
String getIdentifier();
791793

792-
/**
793-
* Gets the keywords (KEYWODS) record of the structure
794-
* @return The keywords in a <code>List&lt;String&gt;</code>
795-
* @since 6.0.0
796-
*/
797-
List<String> getKeywords();
798-
799-
/**
800-
* Sets the KEYWODS record of the structure.
801-
* @param keywords The keywords in a <code>List&lt;String&gt; to set.</code>
802-
* @since 6.0.0
803-
*/
804-
void setKeywords(List<String> keywords);
805794
}

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public class StructureImpl implements Structure {
5757
private List<Bond> ssbonds;
5858
private List<Site> sites;
5959
private String name ;
60-
private List<String> keywords;
6160
private StructureIdentifier structureIdentifier;
6261

6362
private PDBHeader pdbHeader;
@@ -77,7 +76,6 @@ public StructureImpl() {
7776
pdbHeader = new PDBHeader();
7877
ssbonds = new ArrayList<>();
7978
sites = new ArrayList<>();
80-
keywords = new ArrayList<>();
8179
}
8280

8381
/**
@@ -124,7 +122,6 @@ public Structure clone() {
124122
n.setPDBHeader(pdbHeader);
125123
n.setDBRefs(this.getDBRefs());
126124
n.setSites(getSites());
127-
n.setKeywords(this.getKeywords());
128125

129126

130127
// go through each chain and clone chain
@@ -1023,16 +1020,6 @@ public String getPdbId() {
10231020
return pdb_id;
10241021
}
10251022

1026-
/** {@inheritDoc} */
1027-
public List<String> getKeywords() {
1028-
return keywords;
1029-
}
1030-
1031-
/** {@inheritDoc} */
1032-
public void setKeywords(List<String> keywords) {
1033-
this.keywords = keywords;
1034-
}
1035-
10361023
@Override
10371024
public void resetModels() {
10381025
models = new ArrayList<>();

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ public Structure reduce(Structure s) throws StructureException {
186186
newS.setName(this.toString());
187187
newS.setDBRefs(s.getDBRefs());
188188
newS.setBiologicalAssembly(s.isBiologicalAssembly());
189-
newS.setKeywords(s.getKeywords());
190189
newS.getPDBHeader().setDescription(
191190
"sub-range " + ranges + " of " + newS.getPDBCode() + " "
192191
+ s.getPDBHeader().getDescription());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2808,7 +2808,7 @@ private void handlePDBKeywords(List<String> lines) {
28082808
}
28092809
lst.add(keyword);
28102810
}
2811-
structure.setKeywords(lst);
2811+
pdbHeader.setKeywords(lst);
28122812
}
28132813

28142814
/**

biojava-structure/src/main/java/org/biojava/nbio/structure/io/cif/AbstractCifFileSupplier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected CifFile getInternal(Structure structure, List<WrappedAtom> wrappedAtom
4646
.enterBlock(structure.getPDBCode());
4747

4848
blockBuilder.enterStructKeywords().enterText()
49-
.add(String.join(", ", structure.getKeywords()))
49+
.add(String.join(", ", structure.getPDBHeader().getKeywords()))
5050
.leaveColumn().leaveCategory();
5151

5252
if (atomSite.isDefined() && atomSite.getRowCount() > 0) {

biojava-structure/src/main/java/org/biojava/nbio/structure/io/cif/CifStructureConsumerImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -905,14 +905,14 @@ public void consumeStructKeywords(StructKeywords structKeywords) {
905905
keywordsList.add(string.trim());
906906
}
907907
}
908-
structure.setKeywords(keywordsList);
908+
structure.getPDBHeader().setKeywords(keywordsList);
909909

910910
StrColumn pdbxKeywords = structKeywords.getPdbxKeywords();
911911
if (pdbxKeywords.isDefined()) {
912912
String keywords = pdbxKeywords.get(0);
913913
pdbHeader.setClassification(keywords);
914-
//This field should be left empty
915-
// pdbHeader.setDescription(keywords);
914+
//This field should be left empty. TODO The next line should be removed later
915+
pdbHeader.setDescription(keywords);
916916
}
917917
}
918918

biojava-structure/src/test/java/org/biojava/nbio/structure/TestKeywords.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public void testKeywordsOnFiveLines () throws IOException {
1919

2020
PDBFileParser pdbpars = new PDBFileParser();
2121
Structure structure = pdbpars.parsePDBFile(inStream);
22-
List<String> keywords = structure.getKeywords();
23-
assertEquals(keywords.size(), 12);
24-
assertEquals(keywords.get(11), "TRANSCRIPTION REGULATOR");
22+
List<String> keywords = structure.getPDBHeader().getKeywords();
23+
assertEquals(12, keywords.size());
24+
assertEquals("TRANSCRIPTION REGULATOR", keywords.get(11));
2525
}
2626

2727
@Test
@@ -33,9 +33,9 @@ public void testDash() throws IOException {
3333

3434
Structure structure = new PDBFileParser().parsePDBFile(inStream);
3535

36-
List<String> keywords = structure.getKeywords();
37-
assertEquals(keywords.size(), 6);
38-
assertEquals(keywords.get(3), "THIOREDOXIN-FOLD");
39-
assertEquals(keywords.get(4), "ANTI-OXIDATVE DEFENSE SYSTEM");
36+
List<String> keywords = structure.getPDBHeader().getKeywords();
37+
assertEquals(6, keywords.size());
38+
assertEquals("THIOREDOXIN-FOLD", keywords.get(3));
39+
assertEquals("ANTI-OXIDATVE DEFENSE SYSTEM", keywords.get(4));
4040
}
4141
}

0 commit comments

Comments
 (0)