Repository navigation
Expand file tree
/
Copy pathStructureImpl.java
More file actions
1161 lines (926 loc) · 25.6 KB
/
Copy pathStructureImpl.java
File metadata and controls
1161 lines (926 loc) · 25.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* BioJava development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
* For more information on the BioJava project and its aims,
* or to join the biojava-l mailing list, visit the home page
* at:
*
* http://www.biojava.org/
*
* Created on 26.04.2004
* @author Andreas Prlic
*
*/
package org.biojava.nbio.structure;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import org.biojava.nbio.structure.io.FileConvert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Implementation of a PDB Structure. This class
* provides the data contained in a PDB file.
* to get structure objects from different sources
* see io package.
*
* @author Andreas Prlic
* @author Jules Jacobsen
* @since 1.4
* @version %I% %G%
*/
public class StructureImpl implements Structure {
private static final long serialVersionUID = -8344837138032851348L;
private static final Logger logger = LoggerFactory.getLogger(StructureImpl.class);
private String pdb_id ;
private List<Model> models;
private List<EntityInfo> entityInfos;
private List<DBRef> dbrefs;
private List<Bond> ssbonds;
private List<Site> sites;
private String name ;
private StructureIdentifier structureIdentifier;
private PDBHeader pdbHeader;
private Long id;
private boolean biologicalAssembly;
/**
* Constructs a StructureImpl object.
*/
public StructureImpl() {
super();
models = new ArrayList<>();
name = "";
entityInfos = new ArrayList<>();
dbrefs = new ArrayList<>();
pdbHeader = new PDBHeader();
ssbonds = new ArrayList<>();
sites = new ArrayList<>();
}
/** get the ID used by Hibernate
*
* @return the ID used by Hibernate
*/
@Override
public Long getId() {
return id;
}
/** set the ID used by Hibernate
*
* @param id the hibernate ID
*/
@Override
public void setId(Long id) {
this.id = id;
}
/** Construct a Structure object that only contains a single group
*
* @param g group object
*/
public StructureImpl(Group g){
this();
Chain c = new ChainImpl();
c.addGroup(g);
addChain(c);
}
/** construct a Structure object that contains a particular chain
*
* @param c chain
*/
public StructureImpl(Chain c){
this();
addChain(c);
}
/** returns an identical copy of this structure .
* @return an identical Structure object
*/
@Override
public Structure clone() {
// Note: structures are also cloned in SubstructureIdentifier.reduce().
// Changes might need to be made there as well
Structure n = new StructureImpl();
// go through whole substructure and clone ...
// copy structure data
n.setPDBCode(getPDBCode());
n.setName(getName());
//TODO the header data is not being deep-copied, that's a minor issue since it is just some static metadata, but we should recheck this if needed - JD 2014-12-11
n.setPDBHeader(pdbHeader);
n.setDBRefs(this.getDBRefs());
n.setSites(getSites());
// go through each chain and clone chain
for (int i=0;i<nrModels();i++){
List<Chain> cloned_model = new ArrayList<Chain>();
for (int j=0;j<size(i);j++){
Chain cloned_chain = (Chain) getChainByIndex(i,j).clone();
// setting the parent: can only be done from the parent
cloned_chain.setStructure(n);
cloned_model.add(cloned_chain);
}
n.addModel(cloned_model);
}
// deep-copying of entityInfofos is tricky: there's cross references also in the Chains
// beware: if we copy the entityInfos we would also need to reset the references to entityInfos in the individual chains
List<EntityInfo> newEntityInfoList = new ArrayList<EntityInfo>();
for (EntityInfo entityInfo : this.entityInfos) {
EntityInfo newEntityInfo = new EntityInfo(entityInfo); // this sets everything but the chains
for (String asymId:entityInfo.getChainIds()) {
for (int modelNr=0;modelNr<n.nrModels();modelNr++) {
Chain newChain = n.getChain(asymId,modelNr);
if (newChain==null) {
// this actually happens for structure 1msh, which has no chain B for model 29 (clearly a deposition error)
logger.warn("Could not find chain asymId "+asymId+" of model "+modelNr+" while cloning entityInfo "+entityInfo.getMolId()+". Something is wrong!");
continue;
}
newChain.setEntityInfo(newEntityInfo);
newEntityInfo.addChain(newChain);
}
}
newEntityInfoList.add(newEntityInfo);
}
n.setEntityInfos(newEntityInfoList);
// TODO ssbonds are complicated to clone: there are deep references inside Atom objects, how would we do it? - JD 2016-03-03
return n ;
}
/** {@inheritDoc} */
@Override
public Group findGroup(String chainName, String pdbResnum, int modelnr)
throws StructureException {
// if structure is xray there will be only one "model".
if ( modelnr > models.size())
throw new StructureException(" no model nr " + modelnr +
" in this structure. (contains "+models.size()+")");
// first we need to gather all groups with the author id chainName: polymers, non-polymers and waters
Chain polyChain = getPolyChainByPDB(chainName, modelnr);
if(polyChain != null) {
List<Group> groups = new ArrayList<>();
groups.addAll(polyChain.getAtomGroups());
// there can be more than one non-poly chain for a given author id
for (Chain chain: getNonPolyChainsByPDB(chainName, modelnr)) {
groups.addAll(chain.getAtomGroups());
}
Chain water = getWaterChainByPDB(chainName, modelnr);
if (water!=null)
groups.addAll(water.getAtomGroups());
// now iterate over all groups
// in order to find the amino acid that has this pdbRenum.
for (Group g : groups) {
String rnum = g.getResidueNumber().toString();
//System.out.println(g + " >" + rnum + "< >" + pdbResnum + "<");
// we only mutate amino acids
// and ignore hetatoms and nucleotides in this case
if (rnum.equals(pdbResnum)) {
return g;
}
}
}
throw new StructureException("could not find group " + pdbResnum +
" in chain " + chainName);
}
/** {@inheritDoc} */
@Override
public Group findGroup(String chainName, String pdbResnum) throws StructureException
{
return findGroup(chainName, pdbResnum, 0);
}
/** {@inheritDoc} */
@Override
public Chain findChain(String chainName, int modelnr) throws StructureException {
return getChainByPDB(chainName, modelnr);
}
/** {@inheritDoc} */
@Override
public Chain findChain(String chainId) throws StructureException {
return findChain(chainId,0);
}
/** {@inheritDoc} */
@Override
public void setPDBCode (String pdb_id_) {
pdb_id = pdb_id_ ;
}
/** {@inheritDoc} */
@Override
public String getPDBCode () {
return pdb_id ;
}
/** {@inheritDoc} */
@Override
public void setName(String nam) { name = nam; }
/** {@inheritDoc} */
@Override
public String getName() { return name; }
/**
* @return The StructureIdentifier used to create this structure
*/
@Override
public StructureIdentifier getStructureIdentifier() {
return structureIdentifier;
}
/**
* @param structureIdentifier the structureIdentifier corresponding to this structure
*/
@Override
public void setStructureIdentifier(StructureIdentifier structureIdentifier) {
this.structureIdentifier = structureIdentifier;
}
/** {@inheritDoc} */
@Override
public void addChain(Chain chain) {
int modelnr = 0 ;
addChain(chain,modelnr);
}
/** {@inheritDoc} */
@Override
public void addChain(Chain chain, int modelnr) {
// if model has not been initialized, init it!
chain.setStructure(this);
if (models.isEmpty()) {
Model model = new Model();
List<Chain> modelChains = new ArrayList<>() ;
modelChains.add(chain);
model.setChains(modelChains);
models.add(model);
} else {
Model model = models.get(modelnr);
model.addChain(chain);
}
}
/** {@inheritDoc} */
@Override
public Chain getChainByIndex(int number) {
int modelnr = 0 ;
return getChainByIndex(modelnr,number);
}
/** {@inheritDoc} */
@Override
public Chain getChainByIndex(int modelnr,int number) {
Model model = models.get(modelnr);
return model.getChains().get(number);
}
/** {@inheritDoc} */
@Override
public void addModel(List<Chain> modelChains){
for (Chain c: modelChains){
c.setStructure(this);
}
Model model = new Model();
model.setChains(modelChains);
models.add(model);
}
/** {@inheritDoc} */
@Override
public void setChains(List<Chain> chains){
setModel(0,chains);
}
/** {@inheritDoc} */
@Override
public void setModel(int position, List<Chain> modelChains){
if (modelChains == null)
throw new IllegalArgumentException("trying to set model to null!");
for (Chain c: modelChains)
c.setStructure(this);
//System.out.println("model size:" + models.size());
Model model = new Model();
model.setChains(modelChains);
if (models.isEmpty()){
models.add(model);
} else {
models.set(position, model);
}
}
/** String representation.
*
*/
@Override
public String toString(){
String newline = System.getProperty("line.separator");
StringBuilder str = new StringBuilder();
str.append("structure ");
str.append(name);
str.append(" ");
str.append(pdb_id);
str.append(" ");
if ( nrModels()>1 ){
str.append( " models: ");
str.append(nrModels());
str.append(newline) ;
}
str.append(pdbHeader);
str.append(newline) ;
for (int i=0;i<nrModels();i++){
if ( nrModels()>1 ) {
str.append(" model[");
str.append(i);
str.append("]:");
str.append(newline);
}
str.append(" chains:");
str.append(newline);
for (int j=0;j<size(i);j++){
Chain cha = getChainByIndex(i,j);
List<Group> agr = cha.getAtomGroups(GroupType.AMINOACID);
List<Group> hgr = cha.getAtomGroups(GroupType.HETATM);
List<Group> ngr = cha.getAtomGroups(GroupType.NUCLEOTIDE);
str.append("chain ")
.append(j).append(": asymId:")
.append(cha.getId())
.append(" authId:")
.append(cha.getName()).append(" ");
if ( cha.getEntityInfo() != null){
EntityInfo comp = cha.getEntityInfo();
String molName = comp.getDescription();
if ( molName != null){
str.append(molName);
}
String type = comp.getType().toString();
str.append(" (")
.append(type)
.append(")");
}
str.append(newline);
str.append(" length SEQRES: ").append(cha.getSeqResLength());
str.append(" length ATOM: ").append(cha.getAtomLength());
str.append(" aminos: ").append(agr.size());
str.append(" hetatms: ").append(hgr.size());
str.append(" nucleotides: ").append(ngr.size()).append(newline);
}
}
str.append("DBRefs: ").append(dbrefs.size()).append(newline);
for (DBRef dbref: dbrefs){
str.append(dbref.toPDB()).append(newline);
}
str.append("Molecules: ").append(newline);
for (EntityInfo mol : entityInfos) {
str.append(mol).append(newline);
}
return str.toString() ;
}
@Override
public int size() {
int modelnr = 0 ;
if (!models.isEmpty()) {
return models.get(modelnr).getPolyChains().size();
}
else {
return 0 ;
}
}
/** return number of chains of model.
*
*/
@Override
public int size(int modelnr) { return models.get(modelnr).size(); }
// some NMR stuff :
/** return number of models. */
@Override
public int nrModels() {
return models.size() ;
}
/**
* Whether this Structure is a crystallographic structure or not.
* It will first check the experimental technique and if not present it will try
* to guess from the presence of a space group and sensible cell parameters
*
* @return true if crystallographic, false otherwise
*/
@Override
public boolean isCrystallographic() {
if (pdbHeader.getExperimentalTechniques()!=null) {
return ExperimentalTechnique.isCrystallographic(pdbHeader.getExperimentalTechniques());
} else {
// no experimental technique known, we try to guess...
if (pdbHeader.getCrystallographicInfo().getSpaceGroup()!=null) {
// space group defined but no crystal cell: incomplete info, return false
return pdbHeader.getCrystallographicInfo().getCrystalCell() != null &&
pdbHeader.getCrystallographicInfo().getCrystalCell().isCellReasonable();
}
}
return false;
}
/**
* Whether this Structure is a NMR structure or not.
* It will first check the experimental technique and if not present it will try
* to guess from the presence of more than 1 model and from b-factors being 0 in first chain of first model
* @return true if NMR, false otherwise
*/
@Override
public boolean isNmr() {
// old implementation was:
//return nmrflag;
if (pdbHeader.getExperimentalTechniques()!=null) {
return ExperimentalTechnique.isNmr(pdbHeader.getExperimentalTechniques());
} else {
// no experimental technique known, we try to guess...
if (nrModels()>1) {
if (pdbHeader.getCrystallographicInfo().getSpaceGroup()!=null) {
// multimodel, sg defined, but missing cell: must be NMR
if (pdbHeader.getCrystallographicInfo().getCrystalCell()==null)
return true;
// multi-model, sg defined and cell unreasonable: must be NMR
if (!pdbHeader.getCrystallographicInfo().getCrystalCell().isCellReasonable())
return true;
} else {
// multi-model and missing space group: must be NMR
return true;
}
}
}
return false;
}
/** {@inheritDoc} */
@Override
public List<Chain> getChains(int modelIdx){
return getModel(modelIdx);
}
/** {@inheritDoc} */
@Override
public List<Chain> getChains(){
if (models.size()==0) {
return new ArrayList<>(0);
}
return getChains(0);
}
@Override
public List<Chain> getPolyChains() {
if (models.size()==0) {
return new ArrayList<>(0);
}
return getPolyChains(0);
}
@Override
public List<Chain> getPolyChains(int modelIdx) {
return models.get(modelIdx).getPolyChains();
}
@Override
public List<Chain> getNonPolyChains() {
if (models.size()==0) {
return new ArrayList<>(0);
}
return getNonPolyChains(0);
}
@Override
public List<Chain> getNonPolyChains(int modelIdx) {
return models.get(modelIdx).getNonPolyChains();
}
@Override
public List<Chain> getWaterChains() {
if (models.size()==0) {
return new ArrayList<>(0);
}
return getWaterChains(0);
}
@Override
public List<Chain> getWaterChains(int modelIdx) {
return models.get(modelIdx).getWaterChains();
}
/** {@inheritDoc} */
@Override
public void setChains(int modelnr, List<Chain> chains){
for (Chain c: chains){
c.setStructure(this);
}
if (models.size()>modelnr) {
models.remove(modelnr);
}
Model model = new Model();
model.setChains(chains);
models.add(modelnr, model);
}
/** Retrieve all Chains belonging to a model .
*
* @param modelnr an int
* @return a List object
*/
@Override
public List<Chain> getModel(int modelnr) {
return models.get(modelnr).getChains();
}
/** {@inheritDoc} */
@Override
public Chain getChainByPDB(String authId, int modelnr)
throws StructureException{
Chain c = getPolyChainByPDB(authId, modelnr);
if (c==null ) {
throw new StructureException("Could not find chain with authId \"" + authId + "\"" + " for PDB id " + pdb_id + ", model "+modelnr);
}
return c;
}
/** {@inheritDoc} */
@Override
public Chain getChain(String asymId, int modelnr) {
List<Chain> chains = getChains(modelnr);
for (Chain c : chains) {
if (c.getId().equals(asymId)) {
return c;
}
}
return null;
}
/** {@inheritDoc} */
@Override
public Chain getChain(String asymId) {
return getChain(asymId,0);
}
/** {@inheritDoc} */
@Override
public Chain getChainByPDB(String chainId)
throws StructureException{
if(nrModels() < 1 ) {
throw new StructureException("No chains are present.");
}
return getChainByPDB(chainId,0);
}
@Override
public Chain getPolyChain(String asymId) {
return getPolyChain(asymId, 0);
}
@Override
public Chain getPolyChain(String asymId, int modelIdx) {
Model model = models.get(modelIdx);
if (model==null) {
return null;
}
List<Chain> polyChains = model.getPolyChains();
for (Chain c : polyChains){
if (c.getId().equals(asymId))
return c;
}
return null;
}
@Override
public Chain getNonPolyChain(String asymId) {
return getNonPolyChain(asymId, 0);
}
@Override
public Chain getNonPolyChain(String asymId, int modelIdx) {
Model model = models.get(modelIdx);
if (model==null) {
return null;
}
List<Chain> nonpolyChains = model.getNonPolyChains();
for (Chain c : nonpolyChains){
if (c.getId().equals(asymId))
return c;
}
return null;
}
@Override
public Chain getPolyChainByPDB(String authId) {
return getPolyChainByPDB(authId, 0);
}
@Override
public Chain getPolyChainByPDB(String authId, int modelIdx) {
Model model = models.get(modelIdx);
if (model==null) {
return null;
}
List<Chain> polyChains = model.getPolyChains();
for (Chain c : polyChains){
if (c.getName().equals(authId))
return c;
}
return null;
}
@Override
public List<Chain> getNonPolyChainsByPDB(String authId) {
return getNonPolyChainsByPDB(authId, 0);
}
@Override
public List<Chain> getNonPolyChainsByPDB(String authId, int modelIdx) {
List<Chain> chains = new ArrayList<>();
Model model = models.get(modelIdx);
if (model==null) {
return chains;
}
List<Chain> nonpolyChains = model.getNonPolyChains();
for (Chain c : nonpolyChains){
if (c.getName().equals(authId))
chains.add(c);
}
return chains;
}
@Override
public Chain getWaterChain(String asymId) {
return getWaterChain(asymId, 0);
}
@Override
public Chain getWaterChain(String asymId, int modelIdx) {
Model model = models.get(modelIdx);
if (model==null) {
return null;
}
List<Chain> waterChains = model.getWaterChains();
for (Chain c : waterChains){
if (c.getId().equals(asymId))
return c;
}
return null;
}
@Override
public Chain getWaterChainByPDB(String authId) {
return getWaterChainByPDB(authId, 0);
}
@Override
public Chain getWaterChainByPDB(String authId, int modelIdx) {
Model model = models.get(modelIdx);
if (model==null) {
return null;
}
List<Chain> waterChains = model.getWaterChains();
for (Chain c : waterChains){
if (c.getName().equals(authId))
return c;
}
return null;
}
/** {@inheritDoc} */
@Override
public String toPDB() {
FileConvert f = new FileConvert(this) ;
return f.toPDB();
}
/** {@inheritDoc} */
@Override
public String toMMCIF() {
FileConvert f = new FileConvert(this);
return f.toMMCIF();
}
/** {@inheritDoc} */
@Override
public boolean hasChain(String authId) {
int modelnr = 0;
List<Chain> chains = getChains(modelnr);
for (Chain c : chains) {
// we check here with equals because we might want to distinguish between upper and lower case chains!
if (c.getId().equals(authId)) {
return true;
}
}
return false;
}
/** {@inheritDoc} */
@Override
public boolean hasNonPolyChain(String asymId){
int modelnr = 0;
List<Chain> chains = models.get(modelnr).getNonPolyChains();
for (Chain c : chains) {
// we check here with equals because we might want to distinguish between upper and lower case chains!
if (c.getId().equals(asymId)) {
return true;
}
}
return false;
}
/** {@inheritDoc} */
@Override
public boolean hasPdbChain(String authId) {
int modelnr = 0;
List<Chain> chains = getChains(modelnr);
for (Chain c : chains) {
// we check here with equals because we might want to distinguish between upper and lower case chains!
if (c.getName().equals(authId)) {
return true;
}
}
return false;
}
/** {@inheritDoc} */
@Override
public void setEntityInfos(List<EntityInfo> molList){
this.entityInfos = molList;
}
/** {@inheritDoc} */
@Override
public void addEntityInfo(EntityInfo entityInfo) {
this.entityInfos.add(entityInfo);
}
/** {@inheritDoc} */
@Override
public List<EntityInfo> getEntityInfos() {
return entityInfos;
}
/** {@inheritDoc} */
@Override
public EntityInfo getCompoundById(int molId) {
return getEntityById(molId);
}
/** {@inheritDoc} */
@Override
public EntityInfo getEntityById(int entityId) {
for (EntityInfo mol : this.entityInfos){
if (mol.getMolId()==entityId){
return mol;
}
}
return null;
}
/** {@inheritDoc} */
@Override
public List<DBRef> getDBRefs() {
return dbrefs;
}
/** {@inheritDoc} */
@Override
public void setDBRefs(List<DBRef> dbrefs) {
if ( dbrefs == null)
throw new IllegalArgumentException("trying to set dbrefs to null!");
for( DBRef ref : dbrefs){
ref.setParent(this);
}
this.dbrefs = dbrefs;
}
/** {@inheritDoc} */
@Override
public PDBHeader getPDBHeader() {
return pdbHeader;
}
/** {@inheritDoc} */
@Override
public void setPDBHeader(PDBHeader pdbHeader){
this.pdbHeader = pdbHeader;
}
/** {@inheritDoc} */
@Override
public List<Bond> getSSBonds(){
return ssbonds;
}
/** {@inheritDoc} */
@Override
public void setSSBonds(List<Bond> ssbonds){
this.ssbonds = ssbonds;
}
/**
* Adds a single disulfide Bond to this structure
*
* @param ssbond the SSBond.
*/
@Override
public void addSSBond(Bond ssbond){
ssbonds.add(ssbond);
}
/**
* Return whether or not the entry has an associated journal article
* or publication. The JRNL section is not mandatory and thus may not be
* present.
* @return flag if a JournalArticle could be found.
*/
@Override
public boolean hasJournalArticle() {
return this.pdbHeader.hasJournalArticle();
}
/**
* get the associated publication as defined by the JRNL records in a PDB
* file.
* @return a JournalArticle
*/
@Override
public JournalArticle getJournalArticle() {
return this.pdbHeader.getJournalArticle();
}
/**