Skip to content

Commit d39bdee

Browse files
authored
Merge pull request #1099 from biojava/mmtf-deprec
Removing functionality that uses mmtf.rcsb.org, now deprecated
2 parents 2274ea3 + 1a98eeb commit d39bdee

File tree

5 files changed

+11
-102
lines changed

5 files changed

+11
-102
lines changed

biojava-core/src/main/java/org/biojava/nbio/core/util/FileDownloadUtils.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,14 @@ public static void createValidationFiles(URL url, File localDestination, URL has
171171
public static void createValidationFiles(URLConnection resourceUrlConnection, File localDestination, URL hashURL, Hash hash){
172172
long size = resourceUrlConnection.getContentLengthLong();
173173
if(size == -1) {
174-
logger.warn("could not find expected file size for resource {}.", resourceUrlConnection.getURL());
174+
logger.debug("Could not find expected file size for resource {}. Size validation metadata file won't be available for this download.", resourceUrlConnection.getURL());
175175
} else {
176176
logger.debug("Content-Length: {}", size);
177177
File sizeFile = new File(localDestination.getParentFile(), localDestination.getName() + SIZE_EXT);
178178
try (PrintStream sizePrintStream = new PrintStream(sizeFile)) {
179179
sizePrintStream.print(size);
180-
sizePrintStream.close();
181180
} catch (FileNotFoundException e) {
182-
logger.warn("could not write size validation file due to exception: {}", e.getMessage());
181+
logger.warn("Could not write size validation metadata file due to exception: {}", e.getMessage());
183182
}
184183
}
185184

@@ -192,7 +191,7 @@ public static void createValidationFiles(URLConnection resourceUrlConnection, Fi
192191
File hashFile = new File(localDestination.getParentFile(), String.format("%s%s_%s", localDestination.getName(), HASH_EXT, hash));
193192
downloadFile(hashURL, hashFile);
194193
} catch (IOException e) {
195-
logger.warn("could not write validation hash file due to exception: {}", e.getMessage());
194+
logger.warn("Could not write validation hash file due to exception: {}", e.getMessage());
196195
}
197196
}
198197

biojava-structure/src/main/java/demo/DemoMmtfReader.java

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

biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AtomCache.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.biojava.nbio.structure.io.FileParsingParameters;
3939
import org.biojava.nbio.structure.io.LocalPDBDirectory.FetchBehavior;
4040
import org.biojava.nbio.structure.io.LocalPDBDirectory.ObsoleteBehavior;
41-
import org.biojava.nbio.structure.io.MMTFFileReader;
4241
import org.biojava.nbio.structure.io.PDBFileReader;
4342
import org.biojava.nbio.core.util.FileDownloadUtils;
4443
import org.biojava.nbio.structure.io.StructureFiletype;
@@ -829,34 +828,12 @@ public Structure getStructureForPdbId(PdbId pdbId) throws IOException {
829828
case BCIF:
830829
logger.debug("loading from bcif");
831830
return loadStructureFromBcifByPdbId(pdbId);
832-
case MMTF:
833-
logger.debug("loading from mmtf");
834-
return loadStructureFromMmtfByPdbId(pdbId);
835831
case PDB: default:
836832
logger.debug("loading from pdb");
837833
return loadStructureFromPdbByPdbId(pdbId);
838834
}
839835
}
840836

841-
842-
protected Structure loadStructureFromMmtfByPdbId(String pdbId) throws IOException {
843-
return loadStructureFromMmtfByPdbId(new PdbId(pdbId));
844-
}
845-
846-
/**
847-
* Load a {@link Structure} from MMTF either from the local file system.
848-
* @param pdbId the input PDB id
849-
* @return the {@link Structure} object of the parsed structure
850-
* @throws IOException error reading from Web or file system
851-
*/
852-
protected Structure loadStructureFromMmtfByPdbId(PdbId pdbId) throws IOException {
853-
logger.debug("Loading structure {} from mmtf file.", pdbId);
854-
MMTFFileReader reader = new MMTFFileReader();
855-
reader.setFetchBehavior(fetchBehavior);
856-
reader.setObsoleteBehavior(obsoleteBehavior);
857-
return reader.getStructureById(pdbId);
858-
}
859-
860837
protected Structure loadStructureFromCifByPdbId(String pdbId) throws IOException {
861838
return loadStructureFromCifByPdbId(new PdbId(pdbId));
862839
}

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

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,11 @@ public static enum FetchBehavior {
133133
Date d = formatter.parse(LAST_REMEDIATION_DATE_STRING);
134134
t = d.getTime();
135135
} catch (ParseException e){
136-
logger.error("Unexpected error! could not parse LAST_REMEDIATION_DATE: "+e.getMessage());
136+
logger.error("Unexpected error! could not parse LAST_REMEDIATION_DATE: {}", e.getMessage());
137137
}
138138
LAST_REMEDIATION_DATE = t;
139139
}
140140

141-
protected static final String lineSplit = System.getProperty("file.separator");
142-
143141
/** Minimum size for a valid structure file (CIF or PDB), in bytes */
144142
public static final long MIN_PDB_FILE_SIZE = 40; // Empty gzip files are 20bytes. Add a few more for buffer.
145143

@@ -267,8 +265,8 @@ public FileParsingParameters getFileParsingParameters(){
267265
* if {@link #isAutoFetch()} is false. Note that an obsolete entry may still be
268266
* returned even this is FETCH_CURRENT if the entry is found locally.
269267
*
270-
* @param fetchFileEvenIfObsolete Whether to fetch obsolete records
271-
* @see #setFetchCurrent(boolean)
268+
* @param behavior Whether to fetch obsolete records
269+
* @see #setFetchBehavior(FetchBehavior)
272270
* @since 4.0.0
273271
*/
274272
public void setObsoleteBehavior(ObsoleteBehavior behavior) {
@@ -530,9 +528,9 @@ protected File downloadStructure(PdbId pdbId) throws IOException {
530528
}
531529

532530
/**
533-
* Download a file from the ftp server +/- its validation metadata, replacing any existing files if needed
531+
* Download a file from the http server +/- its validation metadata, replacing any existing files if needed
534532
* @param pdbId PDB ID
535-
* @param pathOnServer Path on the FTP server, e.g. data/structures/divided/pdb
533+
* @param pathOnServer Path on the http server, e.g. data/structures/divided/pdb
536534
* @param obsolete Whether or not file should be saved to the obsolete location locally
537535
* @param existingFile if not null and checkServerFileDate is true, the last modified date of the
538536
* server file and this file will be compared to decide whether to download or not
@@ -548,9 +546,7 @@ private File downloadStructure(PdbId pdbId, String pathOnServer, boolean obsolet
548546
String ftp;
549547

550548
String filename = getFilename(id);
551-
if (filename.endsWith(".mmtf.gz")){
552-
ftp = CodecUtils.getMmtfEntryUrl(id, true, false);
553-
} else if (filename.endsWith(".bcif") || filename.endsWith(".bcif.gz")) {
549+
if (filename.endsWith(".bcif") || filename.endsWith(".bcif.gz")) {
554550
// TODO this should be configurable
555551
ftp = DEFAULT_BCIF_FILE_SERVER + filename;
556552
} else {
@@ -578,8 +574,8 @@ private File downloadStructure(PdbId pdbId, String pathOnServer, boolean obsolet
578574
}
579575
}
580576

581-
logger.info("Fetching " + ftp);
582-
logger.info("Writing to "+ realFile);
577+
logger.info("Fetching {}", ftp);
578+
logger.info("Writing to {}", realFile);
583579

584580
FileDownloadUtils.createValidationFiles(url, realFile, null, FileDownloadUtils.Hash.UNKNOWN);
585581
FileDownloadUtils.downloadFile(url, realFile);

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,6 @@ public static void writeToOutputStream(Structure structure, OutputStream outputS
8585
outputStream.write(outputBytes,0,outputBytes.length);
8686
}
8787

88-
89-
/**
90-
* Get a Biojava structure from the mmtf REST service.
91-
* @param pdbId the PDB code of the required structure
92-
* @return a Structure object relating to the input byte array
93-
* @throws IOException
94-
*/
95-
public static Structure readFromWeb(String pdbId) throws IOException {
96-
// Get the reader - this is the bit that people need to implement.
97-
MmtfStructureReader mmtfStructureReader = new MmtfStructureReader();
98-
// Do the inflation
99-
new StructureDataToAdapter(new GenericDecoder(ReaderUtils.getDataFromUrl(pdbId)), mmtfStructureReader);
100-
// Get the structue
101-
return mmtfStructureReader.getStructure();
102-
}
103-
10488
/**
10589
* Read a Biojava structure from an {@link InputStream}
10690
* @param inStream the {@link InputStream} to read from

0 commit comments

Comments
 (0)