|
3 | 3 | import java.io.IOException; |
4 | 4 |
|
5 | 5 | import org.biojava.nbio.structure.Structure; |
6 | | -import org.biojava.nbio.structure.io.mmtf.MmtfStructureReader; |
7 | | -import org.biojava.nbio.structure.io.mmtf.MmtfStructureWriter; |
8 | | -import org.rcsb.mmtf.dataholders.MmtfBean; |
9 | | -import org.rcsb.mmtf.decoder.BeanToGet; |
10 | | -import org.rcsb.mmtf.decoder.GetToInflator; |
11 | | -import org.rcsb.mmtf.deserializers.MessagePackDeserializer; |
12 | | -import org.rcsb.mmtf.encoder.GetToBean; |
13 | | -import org.rcsb.mmtf.encoder.InflatorToGet; |
14 | | -import org.rcsb.mmtf.serializers.MessagePackSerializer; |
| 6 | +import org.biojava.nbio.structure.StructureException; |
| 7 | +import org.biojava.nbio.structure.StructureIO; |
| 8 | +import org.biojava.nbio.structure.io.mmtf.MmtfActions; |
| 9 | +import org.biojava.nbio.structure.io.mmtf.MmtfUtils; |
15 | 10 |
|
16 | 11 | public class DemoMmtfRoundTrip { |
17 | 12 |
|
18 | | - public static Structure roundTrip(Structure structure) throws IOException { |
19 | | - // Set up the transform from the inflator to the get api |
20 | | - InflatorToGet inflatorToGet = new InflatorToGet(); |
21 | | - // Get the writer - this is what people implement |
22 | | - MmtfStructureWriter mmtfStructureWriter = new MmtfStructureWriter(structure); |
23 | | - // Do thte inflation |
24 | | - mmtfStructureWriter.write(inflatorToGet); |
25 | | - // Get the bean |
26 | | - GetToBean getToBean = new GetToBean(inflatorToGet); |
27 | | - // Serialize |
28 | | - MessagePackSerializer messagePackSerializer = new MessagePackSerializer(); |
29 | | - byte[] byteArr = messagePackSerializer.serialize(getToBean.getMmtfBean()); |
30 | | - // Get the reader - this is the bit that people need to implement. |
31 | | - MmtfStructureReader mmtfStructureReader = new MmtfStructureReader(); |
32 | | - // Set up the deserializer |
33 | | - MessagePackDeserializer messagePackDeserializer = new MessagePackDeserializer(); |
34 | | - // Get the data |
35 | | - MmtfBean mmtfBean = messagePackDeserializer.deserialize(byteArr); |
36 | | - // Set up the data API |
37 | | - BeanToGet beanToGet = new BeanToGet(mmtfBean); |
38 | | - // Set up the inflator |
39 | | - GetToInflator getToInflator = new GetToInflator(); |
40 | | - // Do the inflation |
41 | | - getToInflator.read(beanToGet, mmtfStructureReader); |
42 | | - // Get the structue |
43 | | - return mmtfStructureReader.getStructure(); |
| 13 | + public static void main(String[] args) throws IOException, StructureException { |
| 14 | + MmtfUtils.setUpBioJava(); |
| 15 | + Structure structure = StructureIO.getStructure("4cup"); |
| 16 | + // We can do somme comparisons on the round tripped structure |
| 17 | + MmtfActions.roundTrip(structure); |
44 | 18 | } |
| 19 | + |
| 20 | + |
45 | 21 | } |
0 commit comments