1717public class MmtfActions {
1818
1919 /**
20- * Utility function to get a Biojava structure from a byte array .
20+ * Utility function to get a Biojava structure from a file .
2121 * @param inputByteArray Must be uncompressed (i.e. with entropy compression methods like gzip)
2222 * @return a Biojava structure object relating to the input byte array.
2323 * @throws IOException
2424 */
25- public static Structure readBiojavaStruct (String filePath ) throws IOException {
25+ public static Structure readFromFile (String filePath ) throws IOException {
2626 // Get the reader - this is the bit that people need to implement.
2727 MmtfStructureReader mmtfStructureReader = new MmtfStructureReader ();
2828 // Do the inflation
@@ -37,7 +37,7 @@ public static Structure readBiojavaStruct(String filePath) throws IOException {
3737 * @param path the full path of the file to write
3838 * @throws IOException
3939 */
40- public static void writeBiojavaStruct (Structure structure , String path ) throws IOException {
40+ public static void writeToFile (Structure structure , String path ) throws IOException {
4141 // Set up this writer
4242 WriterToEncoder writerToEncoder = new WriterToEncoder ();
4343 // Get the writer - this is what people implement
@@ -46,4 +46,19 @@ public static void writeBiojavaStruct(Structure structure, String path) throws I
4646 WriterUtils .writeDataToFile (writerToEncoder , path );
4747 }
4848
49+
50+ /**
51+ * Utility function to get a Biojava structure from the REST service.
52+ * @param pdbId the PDB code of the required structure
53+ * @return a Biojava structure object relating to the input byte array
54+ * @throws IOException
55+ */
56+ public static Structure readFromWeb (String pdbId ) throws IOException {
57+ // Get the reader - this is the bit that people need to implement.
58+ MmtfStructureReader mmtfStructureReader = new MmtfStructureReader ();
59+ // Do the inflation
60+ new DecoderToReader (new DefaultDecoder (ReaderUtils .getDataFromUrl (pdbId )), mmtfStructureReader );
61+ // Get the structue
62+ return mmtfStructureReader .getStructure ();
63+ }
4964}
0 commit comments