Clover icon

Coverage Report

  1. Project Clover database Wed Jan 7 2026 02:39:37 GMT
  2. Package mc_view

File PDBChain.java

 

Coverage histogram

../img/srcFileCovDistChart7.png
30% of files have more coverage

Code metrics

126
254
18
1
808
575
103
0.41
14.11
18
5.72

Classes

Class Line # Actions
PDBChain 47 254 103
0.6984924769.8%
 

Contributing tests

This file is covered by 67 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package mc_view;
22   
23    import java.awt.Color;
24    import java.util.ArrayList;
25    import java.util.Collection;
26    import java.util.List;
27    import java.util.Locale;
28    import java.util.Vector;
29   
30    import jalview.analysis.AlignSeq;
31    import jalview.datamodel.AlignmentAnnotation;
32    import jalview.datamodel.Annotation;
33    import jalview.datamodel.ContactMatrixI;
34    import jalview.datamodel.Mapping;
35    import jalview.datamodel.Sequence;
36    import jalview.datamodel.SequenceFeature;
37    import jalview.datamodel.SequenceI;
38    import jalview.datamodel.annotations.AnnotationRowBuilder;
39    import jalview.schemes.ColourSchemeI;
40    import jalview.schemes.ResidueProperties;
41    import jalview.structure.StructureImportSettings;
42    import jalview.structure.StructureMapping;
43    import jalview.util.Comparison;
44    import jalview.util.Constants;
45    import jalview.ws.datamodel.MappableContactMatrixI;
46   
 
47    public class PDBChain
48    {
49    public static final String RESNUM_FEATURE = "RESNUM";
50   
51    private static final String IEASTATUS = "IEA:jalview";
52   
53    public String id;
54   
55    public Vector<Bond> bonds = new Vector<>();
56   
57    public Vector<Atom> atoms = new Vector<>();
58   
59    public Vector<Residue> residues = new Vector<>();
60   
61    public int offset;
62   
63    /**
64    * sequence is the sequence extracted by the chain parsing code
65    */
66    public SequenceI sequence;
67   
68    /**
69    * shadow is the sequence created by any other parsing processes (e.g. Jmol,
70    * RNAview)
71    */
72    public SequenceI shadow = null;
73   
74    public boolean isNa = false;
75   
76    public boolean isVisible = true;
77   
78    public int pdbstart = 0;
79   
80    public int pdbend = 0;
81   
82    public int seqstart = 0;
83   
84    public int seqend = 0;
85   
86    public String pdbid = "";
87   
88    AnnotationRowBuilder tfacTemplate = new AnnotationRowBuilder(
89    "Temperature Factor");
90   
 
91  268 toggle public PDBChain(String thePdbid, String theId,
92    AnnotationRowBuilder template)
93    {
94  268 this(thePdbid, theId);
95  268 if (template != null)
96    {
97  79 tfacTemplate = template;
98    }
99    }
100   
101    /**
102    * import chain data assuming Temperature Factor is in the Temperature Factor
103    * column
104    *
105    * @param thePdbid
106    * @param theId
107    */
 
108  315 toggle public PDBChain(String thePdbid, String theId)
109    {
110  315 this.pdbid = thePdbid == null ? thePdbid
111    : thePdbid.toLowerCase(Locale.ROOT);
112  315 this.id = theId;
113    }
114   
115    /**
116    * character used to write newlines
117    */
118    protected String newline = System.getProperty("line.separator");
119   
120    public Mapping shadowMap;
121   
 
122  1 toggle public void setNewlineString(String nl)
123    {
124  1 newline = nl;
125    }
126   
 
127  2 toggle public String getNewlineString()
128    {
129  2 return newline;
130    }
131   
 
132  1 toggle public String print()
133    {
134  1 StringBuilder tmp = new StringBuilder(256);
135   
136  1 for (Bond b : bonds)
137    {
138  3 tmp.append(b.at1.resName).append(" ").append(b.at1.resNumber)
139    .append(" ").append(offset).append(newline);
140    }
141   
142  1 return tmp.toString();
143    }
144   
145    /**
146    * Annotate the residues with their corresponding positions in s1 using the
147    * alignment in as NOTE: This clears all atom.alignmentMapping values on the
148    * structure.
149    *
150    * @param as
151    * @param s1
152    */
 
153  239 toggle public void makeExactMapping(AlignSeq as, SequenceI s1)
154    {
155  239 int pdbpos = as.getSeq2Start() - 2;
156  239 int alignpos = s1.getStart() + as.getSeq1Start() - 3;
157    // first clear out any old alignmentMapping values:
158  239 for (Atom atom : atoms)
159    {
160  24543 atom.alignmentMapping = -1;
161    }
162    // and now trace the alignment onto the atom set.
163  24779 for (int i = 0; i < as.astr1.length(); i++)
164    {
165  24540 if (as.astr1.charAt(i) != '-')
166    {
167  24540 alignpos++;
168    }
169   
170  24540 if (as.astr2.charAt(i) != '-')
171    {
172  24540 pdbpos++;
173    }
174   
175  24540 boolean sameResidue = Comparison.isSameResidue(as.astr1.charAt(i),
176    as.astr2.charAt(i), false);
177  24540 if (sameResidue)
178    {
179  24493 if (pdbpos >= residues.size())
180    {
181  0 continue;
182    }
183  24493 Residue res = residues.elementAt(pdbpos);
184  24493 for (Atom atom : res.atoms)
185    {
186  24496 atom.alignmentMapping = alignpos;
187    }
188    }
189    }
190    }
191   
192    /**
193    * like makeExactMapping but using a sequence mapping object
194    *
195    * @param sqmpping
196    * @param seq
197    */
 
198  0 toggle public void mapChainWith(Mapping sqmpping, SequenceI seq)
199    {
200  0 for (Atom atom : atoms)
201    {
202  0 atom.alignmentMapping = -1;
203    }
204    // and now map sqmapping to the atom set.
205  0 int[] range = sqmpping.locateRange(seq.getStart(), seq.getEnd());
206  0 int r = 0, from, to;
207  0 while (r < range.length)
208    {
209  0 from = range[r++];
210  0 to = range[r++];
211  0 for (int pdbpos = from; pdbpos <= to; pdbpos++)
212    {
213  0 if (pdbpos >= residues.size())
214    {
215  0 continue;
216    }
217  0 Residue res = residues.elementAt(pdbpos);
218  0 for (Atom atom : res.atoms)
219    {
220  0 atom.alignmentMapping = sqmpping.getPosition(pdbpos);
221    }
222    }
223    }
224    }
225   
226    /**
227    * Annotate the residues with their corresponding positions in s1 using the
228    * alignment in as NOTE: This clears all atom.alignmentMapping values on the
229    * structure.
230    *
231    * @param as
232    * @param s1
233    */
 
234  0 toggle public void makeExactMapping(StructureMapping mapping, SequenceI s1)
235    {
236    // first clear out any old alignmentMapping values:
237  0 for (Atom atom : atoms)
238    {
239  0 atom.alignmentMapping = -1;
240    }
241  0 SequenceI ds = s1;
242  0 while (ds.getDatasetSequence() != null)
243    {
244  0 ds = ds.getDatasetSequence();
245    }
246  0 int pdboffset = 0;
247  0 for (Residue res : residues)
248    {
249    // res.number isn't set correctly for discontinuous/mismapped residues
250  0 int seqpos = mapping.getSeqPos(res.atoms.get(0).resNumber);
251  0 char strchar = sequence.getCharAt(pdboffset++);
252  0 if (seqpos == StructureMapping.UNASSIGNED_VALUE)
253    {
254  0 continue;
255    }
256  0 char seqchar = ds.getCharAt(seqpos - ds.getStart());
257   
258  0 boolean sameResidue = Comparison.isSameResidue(seqchar, strchar,
259    false);
260  0 if (sameResidue)
261    {
262  0 for (Atom atom : res.atoms)
263    {
264  0 atom.alignmentMapping = seqpos - 1;
265    }
266    }
267    }
268    }
269   
270    /**
271    * Copies over the RESNUM seqfeatures from the internal chain sequence to the
272    * mapped sequence
273    *
274    * @param seq
275    * @param status
276    * The Status of the transferred annotation
277    *
278    * @param altPDBID
279    * the group id for the features on the destination sequence (e.g.
280    * the official accession ID)
281    */
 
282  238 toggle public void transferRESNUMFeatures(SequenceI seq, String status,
283    String altPDBID)
284    {
285  238 if (altPDBID == null)
286    {
287  0 altPDBID = pdbid;
288    }
289  238 SequenceI sq = seq;
290  474 while (sq != null && sq.getDatasetSequence() != null)
291    {
292  236 sq = sq.getDatasetSequence();
293  236 if (sq == sequence)
294    {
295  0 return;
296    }
297    }
298   
299    /*
300    * Remove any existing features for this chain if they exist ?
301    * SequenceFeature[] seqsfeatures=seq.getSequenceFeatures(); int
302    * totfeat=seqsfeatures.length; // Remove any features for this exact chain
303    * ? for (int i=0; i<seqsfeatures.length; i++) { }
304    */
305  238 if (status == null)
306    {
307  238 status = PDBChain.IEASTATUS;
308    }
309   
310  238 List<SequenceFeature> features = sequence.getSequenceFeatures();
311  238 for (SequenceFeature feature : features)
312    {
313  24537 if (feature.getFeatureGroup() != null
314    && feature.getFeatureGroup().equals(pdbid))
315    {
316  24537 int newBegin = 1
317    + residues.elementAt(feature.getBegin() - offset).atoms
318    .elementAt(0).alignmentMapping;
319  24537 int newEnd = 1 + residues.elementAt(feature.getEnd() - offset).atoms
320    .elementAt(0).alignmentMapping;
321  24537 SequenceFeature tx = new SequenceFeature(feature, newBegin, newEnd,
322    altPDBID, feature.getScore());
323  24537 tx.setStatus(status
324  24537 + ((tx.getStatus() == null || tx.getStatus().length() == 0)
325    ? ""
326    : ":" + tx.getStatus()));
327  24537 if (tx.begin != 0 && tx.end != 0)
328    {
329  24490 sq.addSequenceFeature(tx);
330    }
331    }
332    }
333    }
334   
335    /**
336    * Traverses the list of residues and constructs bonds where CA-to-CA atoms or
337    * P-to-P atoms are found. Also sets the 'isNa' flag if more than 99% of
338    * residues contain a P not a CA.
339    */
 
340  305 toggle public void makeCaBondList()
341    {
342  305 boolean na = false;
343  305 int numNa = 0;
344  43524 for (int i = 0; i < (residues.size() - 1); i++)
345    {
346  43219 Residue tmpres = residues.elementAt(i);
347  43219 Residue tmpres2 = residues.elementAt(i + 1);
348  43219 Atom at1 = tmpres.findAtom("CA");
349  43219 Atom at2 = tmpres2.findAtom("CA");
350  43219 na = false;
351  43219 if ((at1 == null) && (at2 == null))
352    {
353  2 na = true;
354  2 at1 = tmpres.findAtom("P");
355  2 at2 = tmpres2.findAtom("P");
356    }
357  43219 if ((at1 != null) && (at2 != null))
358    {
359  43219 if (at1.chain.equals(at2.chain))
360    {
361  43219 if (na)
362    {
363  2 numNa++;
364    }
365  43219 makeBond(at1, at2);
366    }
367    }
368    else
369    {
370  0 System.out.println("not found " + i);
371    }
372    }
373   
374    /*
375    * If > 99% 'P', flag as nucleotide; note the count doesn't include the last
376    * residue
377    */
378  305 if (residues.size() > 1 && (numNa / (residues.size() - 1) > 0.99))
379    {
380  1 isNa = true;
381    }
382    }
383   
384    /**
385    * Construct a bond from atom1 to atom2 and add it to the list of bonds for
386    * this chain
387    *
388    * @param at1
389    * @param at2
390    */
 
391  43229 toggle public void makeBond(Atom at1, Atom at2)
392    {
393  43229 bonds.addElement(new Bond(at1, at2));
394    }
395   
396    /**
397    * Traverses the list of atoms and
398    * <ul>
399    * <li>constructs a list of Residues, each containing all the atoms that share
400    * the same residue number</li>
401    * <li>adds a RESNUM sequence feature for each position</li>
402    * <li>creates the sequence string</li>
403    * <li>determines if nucleotide</li>
404    * <li>saves the residue number of the first atom as 'offset'</li>
405    * <li>adds temp factor annotation if the flag is set to do so</li>
406    * </ul>
407    *
408    * @param visibleChainAnnotation
409    */
 
410  308 toggle public void makeResidueList(boolean visibleChainAnnotation)
411    {
412  308 int count = 0;
413  308 Object symbol;
414  308 boolean deoxyn = false;
415  308 boolean nucleotide = false;
416  308 StringBuilder seq = new StringBuilder(256);
417  308 Vector<SequenceFeature> resFeatures = new Vector<>();
418  308 Vector<Annotation> resAnnotation = new Vector<>();
419  308 int iSize = atoms.size() - 1;
420  308 int resNumber = -1;
421  308 char insCode = ' ';
422   
423  43841 for (int i = 0; i <= iSize; i++)
424    {
425  43533 Atom tmp = atoms.elementAt(i);
426  43533 resNumber = tmp.resNumber;
427  43533 insCode = tmp.insCode;
428   
429  43533 int res = resNumber;
430  43533 char ins = insCode;
431   
432  43533 if (i == 0)
433    {
434  308 offset = resNumber;
435    }
436   
437  43533 Vector<Atom> resAtoms = new Vector<>();
438    // Add atoms to a vector while the residue number
439    // remains the same as the first atom's resNumber (res)
440  87087 while ((resNumber == res) && (ins == insCode) && (i < atoms.size()))
441    {
442  43554 resAtoms.add(atoms.elementAt(i));
443  43554 i++;
444   
445  43554 if (i < atoms.size())
446    {
447  43246 resNumber = atoms.elementAt(i).resNumber;
448  43246 insCode = atoms.elementAt(i).insCode;
449    }
450    else
451    {
452  308 resNumber++;
453    }
454    }
455   
456    // We need this to keep in step with the outer for i = loop
457  43533 i--;
458   
459    // Add inserted residues as features to the base residue
460  43533 Atom currAtom = resAtoms.get(0);
461  43533 if (currAtom.insCode != ' ' && !residues.isEmpty()
462    && residues.lastElement().atoms
463    .get(0).resNumber == currAtom.resNumber)
464    {
465  0 String desc = currAtom.resName + ":" + currAtom.resNumIns + " "
466    + pdbid + id;
467  0 SequenceFeature sf = new SequenceFeature("INSERTION", desc,
468    offset + count - 1, offset + count - 1, "PDB_INS");
469  0 resFeatures.addElement(sf);
470  0 residues.lastElement().atoms.addAll(resAtoms);
471    }
472    else
473    {
474    // Make a new Residue object with the new atoms vector
475  43533 residues.addElement(new Residue(resAtoms, resNumber - 1, count));
476   
477  43533 Residue tmpres = residues.lastElement();
478  43533 Atom tmpat = tmpres.atoms.get(0);
479    // Make A new SequenceFeature for the current residue numbering
480  43533 String desc = tmpat.resName + ":" + tmpat.resNumIns + " " + pdbid
481    + id;
482  43533 SequenceFeature sf = new SequenceFeature(RESNUM_FEATURE, desc,
483    offset + count, offset + count, pdbid);
484  43533 resFeatures.addElement(sf);
485  43533 resAnnotation.addElement(new Annotation(tmpat.tfactor));
486    // Keep totting up the sequence
487   
488  ? if ((symbol = ResidueProperties.getAA3Hash()
489    .get(tmpat.resName)) == null)
490    {
491  7 String nucname = tmpat.resName.trim();
492    // use the aaIndex rather than call 'toLower' - which would take a bit
493    // more time.
494  7 deoxyn = nucname.length() == 2
495    && ResidueProperties.aaIndex[nucname
496    .charAt(0)] == ResidueProperties.aaIndex['D'];
497  7 if (tmpat.name.equalsIgnoreCase("CA")
498    || ResidueProperties.nucleotideIndex[nucname
499  3 .charAt((deoxyn ? 1 : 0))] == -1)
500    {
501  4 char r = ResidueProperties.getSingleCharacterCode(
502    ResidueProperties.getCanonicalAminoAcid(tmpat.resName));
503  4 seq.append(r == '0' ? 'X' : r);
504    // System.err.println("PDBReader:Null aa3Hash for " +
505    // tmpat.resName);
506    }
507    else
508    {
509    // nucleotide flag
510  3 nucleotide = true;
511  3 seq.append(nucname.charAt((deoxyn ? 1 : 0)));
512    }
513    }
514    else
515    {
516  43526 if (nucleotide)
517    {
518  0 System.err.println(
519    "Warning: mixed nucleotide and amino acid chain.. its gonna do bad things to you!");
520    }
521  43526 seq.append(ResidueProperties.aa[((Integer) symbol).intValue()]);
522    }
523  43533 count++;
524    }
525    }
526   
527  308 if (id.length() < 1)
528    {
529  0 id = " ";
530    }
531  308 isNa = nucleotide;
532  308 sequence = new Sequence(id, seq.toString(), offset, resNumber - 1); // Note:
533    // resNumber-offset
534    // ~=
535    // seq.size()
536    // Add normalised feature scores to RESNUM indicating start/end of sequence
537    // sf.setScore(offset+count);
538   
539    // System.out.println("PDB Sequence is :\nSequence = " + seq);
540    // System.out.println("No of residues = " + residues.size());
541   
542  308 if (StructureImportSettings.isShowSeqFeatures())
543    {
544  294 iSize = resFeatures.size();
545  40475 for (int i = 0; i < iSize; i++)
546    {
547  40181 sequence.addSequenceFeature(resFeatures.elementAt(i));
548  40181 resFeatures.setElementAt(null, i);
549    }
550    }
551  308 if (visibleChainAnnotation)
552    {
553  199 Annotation[] annots = new Annotation[resAnnotation.size()];
554  199 float max = 0f;
555  199 float min = 0f;
556  199 iSize = annots.length;
557  26972 for (int i = 0; i < iSize; i++)
558    {
559  26773 annots[i] = resAnnotation.elementAt(i);
560  26773 tfacTemplate.processAnnotation(annots[i]);
561  26773 max = Math.max(max, annots[i].value);
562  26773 min = Math.min(min, annots[i].value);
563  26773 resAnnotation.setElementAt(null, i);
564    }
565  199 if (tfacTemplate.isHasMinMax())
566    {
567  44 max = tfacTemplate.getMax();
568  44 min = tfacTemplate.getMin();
569    }
570   
571  199 AlignmentAnnotation tfactorann = new AlignmentAnnotation(
572    tfacTemplate.getName(),
573  199 (tfacTemplate.isHasDescription()
574    ? tfacTemplate.getDescription()
575    : tfacTemplate.getName()) + " for " + pdbid + id,
576    annots, min, max, AlignmentAnnotation.LINE_GRAPH);
577  199 tfactorann.setTFType(tfacTemplate.getTFType());
578  199 tfactorann.setCalcId(getClass().getName());
579  199 tfactorann.setProperty(Constants.PDBID, pdbid);
580  199 tfactorann.setProperty(Constants.CHAINID, id);
581   
582  199 tfactorann.setSequenceRef(sequence);
583  199 sequence.addAlignmentAnnotation(tfactorann);
584    }
585    }
586   
587    /**
588    * Colour start/end of bonds by charge
589    * <ul>
590    * <li>ASP and GLU red</li>
591    * <li>LYS and ARG blue</li>
592    * <li>CYS yellow</li>
593    * <li>others light gray</li>
594    * </ul>
595    */
 
596  1 toggle public void setChargeColours()
597    {
598  1 for (Bond b : bonds)
599    {
600  3 if (b.at1 != null && b.at2 != null)
601    {
602  3 b.startCol = getChargeColour(b.at1.resName);
603  3 b.endCol = getChargeColour(b.at2.resName);
604    }
605    else
606    {
607  0 b.startCol = Color.gray;
608  0 b.endCol = Color.gray;
609    }
610    }
611    }
612   
 
613  13 toggle public static Color getChargeColour(String resName)
614    {
615  13 Color result = Color.lightGray;
616  13 if ("ASP".equals(resName) || "GLU".equals(resName))
617    {
618  3 result = Color.red;
619    }
620  10 else if ("LYS".equals(resName) || "ARG".equals(resName))
621    {
622  4 result = Color.blue;
623    }
624  6 else if ("CYS".equals(resName))
625    {
626  3 result = Color.yellow;
627    }
628  13 return result;
629    }
630   
631    /**
632    * Sets the start/end colours of bonds to those of the start/end atoms
633    * according to the specified colour scheme. Note: currently only works for
634    * peptide residues.
635    *
636    * @param cs
637    */
 
638  1 toggle public void setChainColours(ColourSchemeI cs)
639    {
640  1 int index;
641  1 for (Bond b : bonds)
642    {
643  3 try
644    {
645  3 index = ResidueProperties.aa3Hash.get(b.at1.resName).intValue();
646  3 b.startCol = cs.findColour(ResidueProperties.aa[index].charAt(0), 0,
647    null, null, 0f);
648   
649  3 index = ResidueProperties.aa3Hash.get(b.at2.resName).intValue();
650  2 b.endCol = cs.findColour(ResidueProperties.aa[index].charAt(0), 0,
651    null, null, 0f);
652   
653    } catch (Exception e)
654    {
655  1 b.startCol = Color.gray;
656  1 b.endCol = Color.gray;
657    }
658    }
659    }
660   
 
661  1 toggle public void setChainColours(Color col)
662    {
663  1 for (Bond b : bonds)
664    {
665  2 b.startCol = col;
666  2 b.endCol = col;
667    }
668    }
669   
670    /**
671    * copy any sequence annotation onto the sequence mapped using the provided
672    * StructureMapping
673    *
674    * @param mapping
675    * - positional mapping between destination sequence and pdb resnum
676    * @param sqmpping
677    * - mapping between destination sequence and local chain
678    * @return
679    */
 
680  238 toggle public void transferResidueAnnotation(
681    StructureMapping mapping, jalview.datamodel.Mapping sqmpping)
682    {
683  238 SequenceI sq = mapping.getSequence();
684  238 SequenceI dsq = sq;
685  238 if (sqmpping == null)
686    {
687    // SIFTS mappings are recorded in the StructureMapping object...
688   
689  0 sqmpping = mapping.getSeqToPdbMapping();
690    }
691  238 if (sq != null)
692    {
693  474 while (dsq.getDatasetSequence() != null)
694    {
695  236 dsq = dsq.getDatasetSequence();
696    }
697    // any annotation will be transferred onto the dataset sequence
698   
699  238 if (shadow != null && shadow.getAnnotation() != null)
700    {
701    // Shadow is the structure's sequences
702  0 for (AlignmentAnnotation ana : shadow.getAnnotation())
703    {
704    // match on calcId, label and description so annotations from
705    // different structures are preserved
706  0 List<AlignmentAnnotation> transfer = sq.getAlignmentAnnotations(
707    ana.getCalcId(), ana.label, ana.description);
708  0 if (transfer == null || transfer.size() == 0)
709    {
710  0 ContactMatrixI cm = shadow.getContactMatrixFor(ana);
711  0 ana = new AlignmentAnnotation(ana);
712  0 addMetadata(ana);
713    // TODO map contact matrix under mapping
714  0 ana.liftOver(sequence, shadowMap);
715  0 ana.liftOver(dsq, sqmpping);
716  0 dsq.addAlignmentAnnotation(ana);
717  0 if (cm != null)
718    {
719  0 dsq.addContactListFor(ana, cm);
720    }
721    }
722    else
723    {
724  0 continue;
725    }
726    }
727    }
728    else
729    {
730  238 if (sequence != null && sequence.getAnnotation() != null)
731    {
732  220 for (AlignmentAnnotation ana : sequence.getAnnotation())
733    {
734    // match on calcId, label and description so annotations from
735    // different structures are preserved
736  433 List<AlignmentAnnotation> transfer = dsq
737    .getAlignmentAnnotations(ana.getCalcId(), ana.label,
738    ana.description);
739  433 if (transfer == null || transfer.size() == 0)
740    {
741  218 ContactMatrixI cm = sequence.getContactMatrixFor(ana);
742  218 ana = new AlignmentAnnotation(ana);
743  218 addMetadata(ana);
744  218 ana.liftOver(dsq, sqmpping);
745  218 dsq.addAlignmentAnnotation(ana);
746  218 if (cm != null && cm instanceof MappableContactMatrixI)
747    {
748  42 dsq.addContactListFor(ana, ((MappableContactMatrixI) cm)
749    .liftOver(dsq, sqmpping));
750    }
751    }
752    else
753    {
754  215 continue;
755    }
756    }
757    }
758    }
759  238 if (false)
760    {
761    // Useful for debugging mappings - adds annotation for mapped position
762  0 float min = -1, max = 0;
763  0 Annotation[] an = new Annotation[sq.getEnd() - sq.getStart() + 1];
764  0 for (int i = sq.getStart(), j = sq.getEnd(),
765  0 k = 0; i <= j; i++, k++)
766    {
767  0 int prn = mapping.getPDBResNum(k + 1);
768   
769  0 an[k] = new Annotation(prn);
770  0 if (min == -1)
771    {
772  0 min = k;
773  0 max = k;
774    }
775    else
776    {
777  0 if (min > k)
778    {
779  0 min = k;
780    }
781  0 else if (max < k)
782    {
783  0 max = k;
784    }
785    }
786    }
787  0 AlignmentAnnotation pdbresnumannots = new AlignmentAnnotation(
788    "PDB.RESNUM",
789    "PDB Residue Numbering for " + this.pdbid + ":" + this.id,
790    an, min, max, AlignmentAnnotation.LINE_GRAPH);
791   
792  0 sq.addAlignmentAnnotation(pdbresnumannots);
793    }
794    }
795    }
796   
 
797  218 toggle private void addMetadata(AlignmentAnnotation ana)
798    {
799  218 if (pdbid != null && !pdbid.isEmpty())
800    {
801  218 ana.setProperty(Constants.PDBID, pdbid);
802    }
803  218 if (id != null)
804    {
805  218 ana.setProperty(Constants.CHAINID, id);
806    }
807    }
808    }