001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021package org.biojava.nbio.structure.io.mmcif;
022
023import org.biojava.nbio.structure.io.FileParsingParameters;
024import org.biojava.nbio.structure.io.mmcif.chem.MetalBondDistance;
025import org.biojava.nbio.structure.io.mmcif.model.*;
026
027import java.util.ArrayList;
028import java.util.HashMap;
029import java.util.List;
030import java.util.Map;
031
032/**
033 * Created by andreas on 6/9/16.
034 */
035public class MetalBondConsumer implements MMcifConsumer{
036
037
038    Map<String,List<MetalBondDistance>> definitions = new HashMap<>();
039
040    @Override
041    public void documentStart() {
042        definitions.clear();
043    }
044
045    @Override
046    public void documentEnd() {
047
048        // minimize memory consumption
049
050        for  (List<MetalBondDistance> d : definitions.values()){
051            ArrayList<MetalBondDistance> a = (ArrayList<MetalBondDistance>)d;
052
053            a.trimToSize();
054        }
055
056    }
057
058    @Override
059    public void newAtomSite(AtomSite atom) {
060
061    }
062
063    @Override
064    public void newEntity(Entity entity) {
065
066    }
067
068    @Override
069    public void newEntityPoly(EntityPoly entityPoly) {
070
071    }
072
073    @Override
074    public void newEntityPolySeq(EntityPolySeq epolseq) {
075
076    }
077
078    @Override
079    public void newStructAsym(StructAsym sasym) {
080
081    }
082
083    @Override
084    public void setStruct(Struct struct) {
085
086    }
087
088    @Override
089    public void newDatabasePDBrev(DatabasePDBrev dbrev) {
090
091    }
092
093    @Override
094    public void newDatabasePDBrevRecord(DatabasePdbrevRecord dbrev) {
095
096    }
097
098    @Override
099    public void newDatabasePDBremark(DatabasePDBremark remark) {
100
101    }
102
103    @Override
104    public void newExptl(Exptl exptl) {
105
106    }
107
108    @Override
109    public void newCell(Cell cell) {
110
111    }
112
113    @Override
114    public void newSymmetry(Symmetry symmetry) {
115
116    }
117
118    @Override
119    public void newStructNcsOper(StructNcsOper sNcsOper) {
120
121    }
122    
123    @Override 
124    public void newAtomSites(AtomSites atomSites) {
125        
126    }
127
128    @Override
129    public void newStructRef(StructRef sref) {
130
131    }
132
133    @Override
134    public void newStructRefSeq(StructRefSeq sref) {
135
136    }
137
138    @Override
139    public void newStructRefSeqDif(StructRefSeqDif sref) {
140
141    }
142
143    @Override
144    public void newStructSite(StructSite sref) {
145
146    }
147
148    @Override
149    public void newStructSiteGen(StructSiteGen sref) {
150
151    }
152
153    @Override
154    public void newPdbxPolySeqScheme(PdbxPolySeqScheme ppss) {
155
156    }
157
158    @Override
159    public void newPdbxNonPolyScheme(PdbxNonPolyScheme ppss) {
160
161    }
162
163    @Override
164    public void newPdbxEntityNonPoly(PdbxEntityNonPoly pen) {
165
166    }
167
168    @Override
169    public void newStructKeywords(StructKeywords kw) {
170
171    }
172
173    @Override
174    public void newRefine(Refine r) {
175
176    }
177
178    @Override
179    public void newChemComp(ChemComp c) {
180
181    }
182
183    @Override
184    public void newChemCompDescriptor(ChemCompDescriptor ccd) {
185
186    }
187
188    @Override
189    public void newPdbxStructOperList(PdbxStructOperList structOper) {
190
191    }
192
193    @Override
194    public void newPdbxStrucAssembly(PdbxStructAssembly strucAssembly) {
195
196    }
197
198    @Override
199    public void newPdbxStrucAssemblyGen(PdbxStructAssemblyGen strucAssembly) {
200
201    }
202
203    @Override
204    public void newChemCompAtom(ChemCompAtom atom) {
205
206    }
207
208    @Override
209    public void newPdbxChemCompIndentifier(PdbxChemCompIdentifier id) {
210
211    }
212
213    @Override
214    public void newChemCompBond(ChemCompBond bond) {
215
216    }
217
218    @Override
219    public void newPdbxChemCompDescriptor(PdbxChemCompDescriptor desc) {
220
221    }
222
223    @Override
224    public void newEntitySrcGen(EntitySrcGen entitySrcGen) {
225
226    }
227
228    @Override
229    public void newEntitySrcNat(EntitySrcNat entitySrcNat) {
230
231    }
232
233    @Override
234    public void newEntitySrcSyn(EntitySrcSyn entitySrcSyn) {
235
236    }
237
238    @Override
239    public void newStructConn(StructConn structConn) {
240
241    }
242
243    @Override
244    public void newAuditAuthor(AuditAuthor aa) {
245
246    }
247
248    @Override
249    public void newGenericData(String category, List<String> loopFields, List<String> lineData) {
250
251        MetalBondDistance d = new MetalBondDistance();
252
253        d.setAtomType1(lineData.get(0));
254        d.setAtomType2(lineData.get(1));
255        d.setLowerLimit(Float.parseFloat(lineData.get(2)));
256        d.setUpperLimit(Float.parseFloat(lineData.get(3)));
257
258        List<MetalBondDistance> defs = definitions.get(d.getAtomType1());
259
260        if ( defs == null){
261            defs = new ArrayList<>();
262            definitions.put(d.getAtomType1(),defs);
263        }
264
265        defs.add(d);
266
267    }
268
269    @Override
270    public void setFileParsingParameters(FileParsingParameters params) {
271
272    }
273
274    @Override
275    public FileParsingParameters getFileParsingParameters() {
276        return null;
277    }
278
279    public Map<String,List<MetalBondDistance>> getDefinitions(){
280        return definitions;
281    }
282
283        @Override
284        public void newPdbxAuditRevisionHistory(PdbxAuditRevisionHistory history) {
285                // TODO Auto-generated method stub
286                
287        }
288
289        @Override
290        public void newPdbxDatabaseStatus(PdbxDatabaseStatus status) {
291                // TODO Auto-generated method stub
292                
293        }
294}