|
15 | 15 | import org.biojava.nbio.structure.io.mmcif.model.ChemComp; |
16 | 16 | import org.biojava.nbio.structure.quaternary.BioAssemblyInfo; |
17 | 17 | import org.rcsb.mmtf.api.MmtfDecoderInterface; |
| 18 | +import org.rcsb.mmtf.api.MmtfWriter; |
18 | 19 |
|
19 | 20 | /** |
20 | 21 | * Class to take Biojava structure data and covert to the DataApi for encoding. |
21 | 22 | * Must implement all the functions in {@link MmtfDecoderInterface}. |
22 | 23 | * @author Anthony Bradley |
23 | 24 | * |
24 | 25 | */ |
25 | | -public class MmtfStructureWriter { |
| 26 | +public class MmtfStructureWriter implements MmtfWriter { |
26 | 27 |
|
27 | 28 |
|
28 | 29 | private MmtfDecoderInterface mmtfDecoderInterface; |
| 30 | + private Structure structure; |
29 | 31 |
|
30 | 32 | /** |
31 | 33 | * The constructor requires a structre input. |
32 | | - * @param structure ths structure to be encoded |
| 34 | + * @param mmtfDecoderInterface the interface to be used |
| 35 | + * @param structure the structure to be encoded |
33 | 36 | */ |
34 | | - public MmtfStructureWriter(MmtfDecoderInterface mmtfDecoderInterface) { |
35 | | - this.mmtfDecoderInterface = mmtfDecoderInterface; |
| 37 | + public MmtfStructureWriter(Structure data) { |
| 38 | + this.structure = data; |
| 39 | + |
36 | 40 | } |
37 | 41 |
|
38 | 42 |
|
39 | | - public void encodeStructure(Structure structure) { |
| 43 | + public void write(MmtfDecoderInterface decoder) { |
| 44 | + |
| 45 | + this.mmtfDecoderInterface = decoder; |
| 46 | + |
40 | 47 | // Reset structure to consider altloc groups with the same residue number but different group names as seperate groups |
41 | 48 | MmtfUtils.fixMicroheterogenity(structure); |
42 | 49 | // Generate the secondary structure |
@@ -64,15 +71,13 @@ public void encodeStructure(Structure structure) { |
64 | 71 | Chain chain = modelChains.get(chainInModelIndex); |
65 | 72 | List<Group> groups = chain.getAtomGroups(); |
66 | 73 | List<Group> sequenceGroups = chain.getSeqResGroups(); |
67 | | - // TODO we need to include the sequence to group mapping information.... |
68 | 74 | mmtfDecoderInterface.setChainInfo(chain.getChainID(), chain.getInternalChainID(), groups.size()); |
69 | 75 | for(int groupInChainIndex=0; groupInChainIndex<groups.size(); groupInChainIndex++){ |
70 | 76 | // Get the major compy of this group |
71 | 77 | Group group = groups.get(groupInChainIndex); |
72 | 78 | List<Atom> atomsInGroup = MmtfUtils.getAtomsForGroup(group); |
73 | 79 | // Get the group type |
74 | 80 | ChemComp chemComp = group.getChemComp(); |
75 | | - // TODO We need to specify what type of group is being added |
76 | 81 | mmtfDecoderInterface.setGroupInfo(group.getPDBName(), group.getResidueNumber().getSeqNum(), group.getResidueNumber().getInsCode().charValue(), |
77 | 82 | chemComp.getPdbx_type(), atomsInGroup.size(), chemComp.getOne_letter_code().charAt(0), sequenceGroups.indexOf(group)); |
78 | 83 | for (Atom atom : atomsInGroup){ |
@@ -155,4 +160,5 @@ private void storeBioassemblyInformation(Map<String, Integer> chainIdToIndexMap, |
155 | 160 | } |
156 | 161 | } |
157 | 162 | } |
| 163 | + |
158 | 164 | } |
0 commit comments