Skip to content

Commit 6b3bdb0

Browse files
committed
Honor prefixes for StructureNames
All sources support a prefix to force parsing. For instance, FILE:1abc will be parsed as a filename, despite looking like a PDB entry. One possible exception is identifiers of the form file:/absolute/path, which are interpreted as URLs rather than FILEs (with equivalent results). However, relative paths and paths containing home directories are not valid URLs so the source will be set unambiguously as FILE. This commit also contains some misc bug fixes, identified by a much more comprehensive test suite: - getPdbId() returns upper-case results for valid 4-letter identifiers - clarify order of guessing - Documentation improvements
1 parent 2e35da5 commit 6b3bdb0

7 files changed

Lines changed: 349 additions & 145 deletions

File tree

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ public SubstructureIdentifier(String id) {
8686
if(1 > idRange.length || idRange.length > 2 ) {
8787
throw new IllegalArgumentException(String.format("Malformed %s: %s",getClass().getSimpleName(),id));
8888
}
89-
this.pdbId = idRange[0];
90-
if(this.pdbId.length() != 4) {
89+
if(idRange[0].length() != 4) {
90+
this.pdbId = idRange[0];
9191
// Changed from Exception to a warning to support files and stuff -sbliven 2015/01/22
9292
logger.warn(String.format("Unrecognized PDB code %s",this.pdbId));
93+
} else {
94+
this.pdbId = idRange[0].toUpperCase();
9395
}
9496

9597
if( idRange.length == 2) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public Structure loadStructure(AtomCache cache) throws StructureException,
177177
public static String guessPDBID(String name) {
178178
Matcher match = PDBID_REGEX.matcher(name);
179179
if(match.matches()) {
180-
return match.group(1);
180+
return match.group(1).toUpperCase();
181181
} else {
182182
// Give up if doesn't match
183183
return null;

0 commit comments

Comments
 (0)