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.ResidueType;
025import org.biojava.nbio.structure.io.mmcif.model.*;
026import org.slf4j.Logger;
027import org.slf4j.LoggerFactory;
028
029import java.util.List;
030
031public class ChemCompConsumer implements MMcifConsumer {
032
033        private static final Logger logger = LoggerFactory.getLogger(ChemCompConsumer.class);
034
035        ChemicalComponentDictionary dictionary;
036
037        String latestChemCompId;
038        public ChemCompConsumer(){
039                dictionary = new ChemicalComponentDictionary();
040        }
041
042        @Override
043        public void documentStart() {
044
045
046        }
047
048        public ChemicalComponentDictionary getDictionary(){
049                return dictionary;
050        }
051
052        @Override
053        public void newChemComp(ChemComp c) {
054
055                if ( c.getId() == null)
056                        logger.warn("chem comp ID == null " + c);
057
058                latestChemCompId = c.getId();
059                dictionary.addChemComp(c);
060                if ( c.getResidueType() == ResidueType.nonPolymer)
061                        return;
062
063                if ( c.getResidueType() == ResidueType.saccharide)
064                        return;
065
066                if ( c.getResidueType() == ResidueType.dSaccharide)
067                        return;
068
069                //if ( c.isStandard())
070                //      System.out.println(c);
071        }
072
073        @Override
074        public void documentEnd() {
075
076
077        }
078
079        @Override
080        public void newAtomSite(AtomSite atom) {
081
082
083        }
084
085        @Override
086        public void newDatabasePDBremark(DatabasePDBremark remark) {
087
088
089        }
090
091        @Override
092        public void newDatabasePDBrev(DatabasePDBrev dbrev) {
093
094
095        }
096
097        @Override
098        public void newDatabasePDBrevRecord(DatabasePdbrevRecord dbrev) {
099
100        }
101
102        @Override
103        public void newEntity(Entity entity) {
104
105
106        }
107
108        @Override
109        public void newEntityPolySeq(EntityPolySeq epolseq) {
110
111
112        }
113
114        @Override
115        public void newExptl(Exptl exptl) {
116
117
118        }
119
120        @Override
121        public void newCell(Cell cell) {
122
123        }
124
125        @Override
126        public void newSymmetry(Symmetry symmetry) {
127
128        }
129
130        @Override
131        public void newStructNcsOper(StructNcsOper sNcsOper) {
132
133        }
134        
135        @Override
136        public void newAtomSites(AtomSites atomSites) {
137                
138        }
139
140        @Override
141        public void newPdbxEntityNonPoly(PdbxEntityNonPoly pen) {
142
143
144        }
145
146        @Override
147        public void newPdbxNonPolyScheme(PdbxNonPolyScheme ppss) {
148
149
150        }
151
152        @Override
153        public void newPdbxPolySeqScheme(PdbxPolySeqScheme ppss) {
154
155
156        }
157
158        @Override
159        public void newRefine(Refine r) {
160
161
162        }
163
164        @Override
165        public void newStructAsym(StructAsym sasym) {
166
167
168        }
169
170        @Override
171        public void newStructKeywords(StructKeywords kw) {
172
173
174        }
175
176        @Override
177        public void newStructRef(StructRef sref) {
178
179
180        }
181
182        @Override
183        public void newStructRefSeq(StructRefSeq sref) {
184
185
186        }
187
188        @Override
189        public void newStructRefSeqDif(StructRefSeqDif sref) {
190
191
192        }
193
194        @Override
195        public void setStruct(Struct struct) {
196
197
198        }
199
200        @Override
201        public void newGenericData(String category, List<String> loopFields,
202                        List<String> lineData) {
203                //System.out.println("unhandled category: " + category);
204
205        }
206
207
208        @Override
209        public void newAuditAuthor(AuditAuthor aa)
210        {
211
212
213        }
214
215        @Override
216        public FileParsingParameters getFileParsingParameters()
217        {
218                // can be ingored in this case...
219                return null;
220        }
221
222        @Override
223        public void setFileParsingParameters(FileParsingParameters params)
224        {
225
226
227        }
228
229        @Override
230        public void newChemCompDescriptor(ChemCompDescriptor ccd) {
231                ChemComp cc = dictionary.getChemComp(latestChemCompId);
232                cc.getDescriptors().add(ccd);
233
234        }
235
236        @Override
237        public void newPdbxStructOperList(PdbxStructOperList structOper) {
238
239
240        }
241
242        @Override
243        public void newPdbxStrucAssembly(PdbxStructAssembly strucAssembly) {
244
245
246        }
247
248        @Override
249        public void newPdbxStrucAssemblyGen(PdbxStructAssemblyGen strucAssembly) {
250
251
252        }
253
254        @Override
255        public void newChemCompAtom(ChemCompAtom atom) {
256                dictionary.getChemComp(latestChemCompId).getAtoms().add(atom);
257        }
258
259        @Override
260        public void newPdbxChemCompIndentifier(PdbxChemCompIdentifier id) {
261
262
263        }
264
265        @Override
266        public void newChemCompBond(ChemCompBond bond) {
267                dictionary.getChemComp(latestChemCompId).getBonds().add(bond);
268        }
269
270        @Override
271        public void newPdbxChemCompDescriptor(PdbxChemCompDescriptor desc) {
272
273
274        }
275
276        @Override
277        public void newEntitySrcGen(EntitySrcGen entitySrcGen) {
278
279
280        }
281        @Override
282        public void newEntitySrcNat(EntitySrcNat entitySrcNat) {
283
284
285        }
286
287        @Override
288        public void newEntitySrcSyn(EntitySrcSyn entitySrcSyn) {
289
290
291        }
292
293        @Override
294        public void newStructConn(StructConn structConn) {
295
296
297        }
298
299        @Override
300        public void newStructSiteGen(StructSiteGen gen) {
301
302        }
303
304        @Override
305        public void newStructSite(StructSite site) {
306
307        }
308
309        @Override
310        public void newEntityPoly(EntityPoly entityPoly) {
311
312                
313        }
314
315        @Override
316        public void newPdbxAuditRevisionHistory(PdbxAuditRevisionHistory history) {
317                // TODO Auto-generated method stub
318                
319        }
320
321        @Override
322        public void newPdbxDatabaseStatus(PdbxDatabaseStatus status) {
323                // TODO Auto-generated method stub
324                
325        }
326}
327