Skip to content

Commit c84cf73

Browse files
committed
Handling some nulls in PdbId creation, #1019
1 parent f5791b6 commit c84cf73

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ public SubstructureIdentifier(String id) {
117117
* Create a new identifier based on a set of ranges.
118118
*
119119
* If ranges is empty, includes all residues.
120-
* @param pdbId
121-
* @param ranges
120+
* @param pdbId a pdb id, can't be null
121+
* @param ranges the ranges
122122
*/
123123
public SubstructureIdentifier(String pdbId, List<ResidueRange> ranges) {
124124
this(new PdbId(pdbId), ranges);

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ public SubstructureIdentifier toCanonical() throws StructureException{
122122
String path = url.getPath();
123123
pdbId = guessPDBID(path.substring(path.lastIndexOf("/") + 1));
124124
}
125-
return new SubstructureIdentifier(new PdbId(pdbId), ranges);
125+
PdbId pdbIdObj = null;
126+
if (pdbId != null) {
127+
pdbIdObj = new PdbId(pdbId);
128+
}
129+
return new SubstructureIdentifier(pdbIdObj, ranges);
126130
}
127131

128132
@Override

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ public void finalizeStructure() {
167167
@Override
168168
public void initStructure(int totalNumBonds, int totalNumAtoms, int totalNumGroups,
169169
int totalNumChains, int totalNumModels, String modelId) {
170-
structure.setPdbId(new PdbId(modelId));
170+
if (modelId != null) {
171+
structure.setPdbId(new PdbId(modelId));
172+
}
171173
allAtoms = new Atom[totalNumAtoms];
172174
}
173175

biojava-structure/src/main/java/org/biojava/nbio/structure/scop/ScopDomain.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,10 @@ public PdbId getPdbId() {
138138
*/
139139
@Deprecated
140140
public void setPdbId(String pdbId) {
141-
if(pdbId == null) this.pdbId = null;
142-
this.pdbId = new PdbId(pdbId);
141+
if (pdbId == null)
142+
this.pdbId = null;
143+
else
144+
this.pdbId = new PdbId(pdbId);
143145
}
144146

145147

0 commit comments

Comments
 (0)