Clover icon

Coverage Report

  1. Project Clover database Tue Nov 18 2025 10:51:49 GMT
  2. Package mc_view

File PDBChain.java

 

Coverage histogram

../img/srcFileCovDistChart8.png
22% of files have more coverage

Code metrics

120
241
17
1
774
549
99
0.41
14.18
17
5.82

Classes

Class Line # Actions
PDBChain 47 241 99
0.7354497373.5%
 

Contributing tests

This file is covered by 80 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  335 toggle public PDBChain(String thePdbid, String theId,
92    AnnotationRowBuilder template)
93    {
94  335 this(thePdbid, theId);
95  335 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  382 toggle public PDBChain(String thePdbid, String theId)
109    {
110  382 this.pdbid = thePdbid == null ? thePdbid
111    : thePdbid.toLowerCase(Locale.ROOT);
112  382 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  262 toggle public void makeExactMapping(AlignSeq as, SequenceI s1)
154    {
155  262 int pdbpos = as.getSeq2Start() - 2;
156  262 int alignpos = s1.getStart() + as.getSeq1Start() - 3;
157    // first clear out any old alignmentMapping values:
158  262 for (Atom atom : atoms)
159    {
160  29012 atom.alignmentMapping = -1;
161    }
162    // and now trace the alignment onto the atom set.
163  29267 for (int i = 0; i < as.astr1.length(); i++)
164    {
165  29005 if (as.astr1.charAt(i) != '-')
166    {
167  29005 alignpos++;
168    }
169   
170  29005 if (as.astr2.charAt(i) != '-')
171    {
172  29005 pdbpos++;
173    }
174   
175  29005 boolean sameResidue = Comparison.isSameResidue(as.astr1.charAt(i),
176    as.astr2.charAt(i), false);
177  29005 if (sameResidue)
178    {
179  28960 if (pdbpos >= residues.size())
180    {
181  0 continue;
182    }
183  28960 Residue res = residues.elementAt(pdbpos);
184  28960 for (Atom atom : res.atoms)
185    {
186  28963 atom.alignmentMapping = alignpos;
187    }
188    }
189    }
190    }
191   
192    /**
193    * Annotate the residues with their corresponding positions in s1 using the
194    * alignment in as NOTE: This clears all atom.alignmentMapping values on the
195    * structure.
196    *
197    * @param as
198    * @param s1
199    */
 
200  0 toggle public void makeExactMapping(StructureMapping mapping, SequenceI s1)
201    {
202    // first clear out any old alignmentMapping values:
203  0 for (Atom atom : atoms)
204    {
205  0 atom.alignmentMapping = -1;
206    }
207  0 SequenceI ds = s1;
208  0 while (ds.getDatasetSequence() != null)
209    {
210  0 ds = ds.getDatasetSequence();
211    }
212  0 int pdboffset = 0;
213  0 for (Residue res : residues)
214    {
215    // res.number isn't set correctly for discontinuous/mismapped residues
216  0 int seqpos = mapping.getSeqPos(res.atoms.get(0).resNumber);
217  0 char strchar = sequence.getCharAt(pdboffset++);
218  0 if (seqpos == StructureMapping.UNASSIGNED_VALUE)
219    {
220  0 continue;
221    }
222  0 char seqchar = ds.getCharAt(seqpos - ds.getStart());
223   
224  0 boolean sameResidue = Comparison.isSameResidue(seqchar, strchar,
225    false);
226  0 if (sameResidue)
227    {
228  0 for (Atom atom : res.atoms)
229    {
230  0 atom.alignmentMapping = seqpos - 1;
231    }
232    }
233    }
234    }
235   
236    /**
237    * Copies over the RESNUM seqfeatures from the internal chain sequence to the
238    * mapped sequence
239    *
240    * @param seq
241    * @param status
242    * The Status of the transferred annotation
243    *
244    * @param altPDBID
245    * the group id for the features on the destination sequence (e.g.
246    * the official accession ID)
247    */
 
248  261 toggle public void transferRESNUMFeatures(SequenceI seq, String status,
249    String altPDBID)
250    {
251  261 if (altPDBID == null)
252    {
253  0 altPDBID = pdbid;
254    }
255  261 SequenceI sq = seq;
256  520 while (sq != null && sq.getDatasetSequence() != null)
257    {
258  259 sq = sq.getDatasetSequence();
259  259 if (sq == sequence)
260    {
261  0 return;
262    }
263    }
264   
265    /*
266    * Remove any existing features for this chain if they exist ?
267    * SequenceFeature[] seqsfeatures=seq.getSequenceFeatures(); int
268    * totfeat=seqsfeatures.length; // Remove any features for this exact chain
269    * ? for (int i=0; i<seqsfeatures.length; i++) { }
270    */
271  261 if (status == null)
272    {
273  261 status = PDBChain.IEASTATUS;
274    }
275   
276  261 List<SequenceFeature> features = sequence.getSequenceFeatures();
277  261 for (SequenceFeature feature : features)
278    {
279  29006 if (feature.getFeatureGroup() != null
280    && feature.getFeatureGroup().equals(pdbid))
281    {
282  29006 int newBegin = 1
283    + residues.elementAt(feature.getBegin() - offset).atoms
284    .elementAt(0).alignmentMapping;
285  29006 int newEnd = 1 + residues.elementAt(feature.getEnd() - offset).atoms
286    .elementAt(0).alignmentMapping;
287  29006 SequenceFeature tx = new SequenceFeature(feature, newBegin, newEnd,
288    altPDBID, feature.getScore());
289  29006 tx.setStatus(status
290  29006 + ((tx.getStatus() == null || tx.getStatus().length() == 0)
291    ? ""
292    : ":" + tx.getStatus()));
293  29006 if (tx.begin != 0 && tx.end != 0)
294    {
295  28957 sq.addSequenceFeature(tx);
296    }
297    }
298    }
299    }
300   
301    /**
302    * Traverses the list of residues and constructs bonds where CA-to-CA atoms or
303    * P-to-P atoms are found. Also sets the 'isNa' flag if more than 99% of
304    * residues contain a P not a CA.
305    */
 
306  372 toggle public void makeCaBondList()
307    {
308  372 boolean na = false;
309  372 int numNa = 0;
310  55847 for (int i = 0; i < (residues.size() - 1); i++)
311    {
312  55475 Residue tmpres = residues.elementAt(i);
313  55475 Residue tmpres2 = residues.elementAt(i + 1);
314  55475 Atom at1 = tmpres.findAtom("CA");
315  55475 Atom at2 = tmpres2.findAtom("CA");
316  55475 na = false;
317  55475 if ((at1 == null) && (at2 == null))
318    {
319  2 na = true;
320  2 at1 = tmpres.findAtom("P");
321  2 at2 = tmpres2.findAtom("P");
322    }
323  55475 if ((at1 != null) && (at2 != null))
324    {
325  55475 if (at1.chain.equals(at2.chain))
326    {
327  55475 if (na)
328    {
329  2 numNa++;
330    }
331  55475 makeBond(at1, at2);
332    }
333    }
334    else
335    {
336  0 System.out.println("not found " + i);
337    }
338    }
339   
340    /*
341    * If > 99% 'P', flag as nucleotide; note the count doesn't include the last
342    * residue
343    */
344  372 if (residues.size() > 1 && (numNa / (residues.size() - 1) > 0.99))
345    {
346  1 isNa = true;
347    }
348    }
349   
350    /**
351    * Construct a bond from atom1 to atom2 and add it to the list of bonds for
352    * this chain
353    *
354    * @param at1
355    * @param at2
356    */
 
357  55485 toggle public void makeBond(Atom at1, Atom at2)
358    {
359  55485 bonds.addElement(new Bond(at1, at2));
360    }
361   
362    /**
363    * Traverses the list of atoms and
364    * <ul>
365    * <li>constructs a list of Residues, each containing all the atoms that share
366    * the same residue number</li>
367    * <li>adds a RESNUM sequence feature for each position</li>
368    * <li>creates the sequence string</li>
369    * <li>determines if nucleotide</li>
370    * <li>saves the residue number of the first atom as 'offset'</li>
371    * <li>adds temp factor annotation if the flag is set to do so</li>
372    * </ul>
373    *
374    * @param visibleChainAnnotation
375    */
 
376  375 toggle public void makeResidueList(boolean visibleChainAnnotation)
377    {
378  375 int count = 0;
379  375 Object symbol;
380  375 boolean deoxyn = false;
381  375 boolean nucleotide = false;
382  375 StringBuilder seq = new StringBuilder(256);
383  375 Vector<SequenceFeature> resFeatures = new Vector<>();
384  375 Vector<Annotation> resAnnotation = new Vector<>();
385  375 int iSize = atoms.size() - 1;
386  375 int resNumber = -1;
387  375 char insCode = ' ';
388   
389  56231 for (int i = 0; i <= iSize; i++)
390    {
391  55856 Atom tmp = atoms.elementAt(i);
392  55856 resNumber = tmp.resNumber;
393  55856 insCode = tmp.insCode;
394   
395  55856 int res = resNumber;
396  55856 char ins = insCode;
397   
398  55856 if (i == 0)
399    {
400  375 offset = resNumber;
401    }
402   
403  55856 Vector<Atom> resAtoms = new Vector<>();
404    // Add atoms to a vector while the residue number
405    // remains the same as the first atom's resNumber (res)
406  111733 while ((resNumber == res) && (ins == insCode) && (i < atoms.size()))
407    {
408  55877 resAtoms.add(atoms.elementAt(i));
409  55877 i++;
410   
411  55877 if (i < atoms.size())
412    {
413  55502 resNumber = atoms.elementAt(i).resNumber;
414  55502 insCode = atoms.elementAt(i).insCode;
415    }
416    else
417    {
418  375 resNumber++;
419    }
420    }
421   
422    // We need this to keep in step with the outer for i = loop
423  55856 i--;
424   
425    // Add inserted residues as features to the base residue
426  55856 Atom currAtom = resAtoms.get(0);
427  55856 if (currAtom.insCode != ' ' && !residues.isEmpty()
428    && residues.lastElement().atoms
429    .get(0).resNumber == currAtom.resNumber)
430    {
431  0 String desc = currAtom.resName + ":" + currAtom.resNumIns + " "
432    + pdbid + id;
433  0 SequenceFeature sf = new SequenceFeature("INSERTION", desc,
434    offset + count - 1, offset + count - 1, "PDB_INS");
435  0 resFeatures.addElement(sf);
436  0 residues.lastElement().atoms.addAll(resAtoms);
437    }
438    else
439    {
440    // Make a new Residue object with the new atoms vector
441  55856 residues.addElement(new Residue(resAtoms, resNumber - 1, count));
442   
443  55856 Residue tmpres = residues.lastElement();
444  55856 Atom tmpat = tmpres.atoms.get(0);
445    // Make A new SequenceFeature for the current residue numbering
446  55856 String desc = tmpat.resName + ":" + tmpat.resNumIns + " " + pdbid
447    + id;
448  55856 SequenceFeature sf = new SequenceFeature(RESNUM_FEATURE, desc,
449    offset + count, offset + count, pdbid);
450  55856 resFeatures.addElement(sf);
451  55856 resAnnotation.addElement(new Annotation(tmpat.tfactor));
452    // Keep totting up the sequence
453   
454  ? if ((symbol = ResidueProperties.getAA3Hash()
455    .get(tmpat.resName)) == null)
456    {
457  7 String nucname = tmpat.resName.trim();
458    // use the aaIndex rather than call 'toLower' - which would take a bit
459    // more time.
460  7 deoxyn = nucname.length() == 2
461    && ResidueProperties.aaIndex[nucname
462    .charAt(0)] == ResidueProperties.aaIndex['D'];
463  7 if (tmpat.name.equalsIgnoreCase("CA")
464    || ResidueProperties.nucleotideIndex[nucname
465  3 .charAt((deoxyn ? 1 : 0))] == -1)
466    {
467  4 char r = ResidueProperties.getSingleCharacterCode(
468    ResidueProperties.getCanonicalAminoAcid(tmpat.resName));
469  4 seq.append(r == '0' ? 'X' : r);
470    // System.err.println("PDBReader:Null aa3Hash for " +
471    // tmpat.resName);
472    }
473    else
474    {
475    // nucleotide flag
476  3 nucleotide = true;
477  3 seq.append(nucname.charAt((deoxyn ? 1 : 0)));
478    }
479    }
480    else
481    {
482  55849 if (nucleotide)
483    {
484  0 System.err.println(
485    "Warning: mixed nucleotide and amino acid chain.. its gonna do bad things to you!");
486    }
487  55849 seq.append(ResidueProperties.aa[((Integer) symbol).intValue()]);
488    }
489  55856 count++;
490    }
491    }
492   
493  375 if (id.length() < 1)
494    {
495  0 id = " ";
496    }
497  375 isNa = nucleotide;
498  375 sequence = new Sequence(id, seq.toString(), offset, resNumber - 1); // Note:
499    // resNumber-offset
500    // ~=
501    // seq.size()
502    // Add normalised feature scores to RESNUM indicating start/end of sequence
503    // sf.setScore(offset+count);
504   
505    // System.out.println("PDB Sequence is :\nSequence = " + seq);
506    // System.out.println("No of residues = " + residues.size());
507   
508  375 if (StructureImportSettings.isShowSeqFeatures())
509    {
510  361 iSize = resFeatures.size();
511  52865 for (int i = 0; i < iSize; i++)
512    {
513  52504 sequence.addSequenceFeature(resFeatures.elementAt(i));
514  52504 resFeatures.setElementAt(null, i);
515    }
516    }
517  375 if (visibleChainAnnotation)
518    {
519  235 Annotation[] annots = new Annotation[resAnnotation.size()];
520  235 float max = 0f;
521  235 float min = 0f;
522  235 iSize = annots.length;
523  37275 for (int i = 0; i < iSize; i++)
524    {
525  37040 annots[i] = resAnnotation.elementAt(i);
526  37040 tfacTemplate.processAnnotation(annots[i]);
527  37040 max = Math.max(max, annots[i].value);
528  37040 min = Math.min(min, annots[i].value);
529  37040 resAnnotation.setElementAt(null, i);
530    }
531  235 if (tfacTemplate.isHasMinMax())
532    {
533  44 max = tfacTemplate.getMax();
534  44 min = tfacTemplate.getMin();
535    }
536   
537  235 AlignmentAnnotation tfactorann = new AlignmentAnnotation(
538    tfacTemplate.getName(),
539  235 (tfacTemplate.isHasDescription()
540    ? tfacTemplate.getDescription()
541    : tfacTemplate.getName()) + " for " + pdbid + id,
542    annots, min, max, AlignmentAnnotation.LINE_GRAPH);
543  235 tfactorann.setTFType(tfacTemplate.getTFType());
544  235 tfactorann.setCalcId(getClass().getName());
545  235 tfactorann.setProperty(Constants.PDBID, pdbid);
546  235 tfactorann.setProperty(Constants.CHAINID, id);
547   
548  235 tfactorann.setSequenceRef(sequence);
549  235 sequence.addAlignmentAnnotation(tfactorann);
550    }
551    }
552   
553    /**
554    * Colour start/end of bonds by charge
555    * <ul>
556    * <li>ASP and GLU red</li>
557    * <li>LYS and ARG blue</li>
558    * <li>CYS yellow</li>
559    * <li>others light gray</li>
560    * </ul>
561    */
 
562  1 toggle public void setChargeColours()
563    {
564  1 for (Bond b : bonds)
565    {
566  3 if (b.at1 != null && b.at2 != null)
567    {
568  3 b.startCol = getChargeColour(b.at1.resName);
569  3 b.endCol = getChargeColour(b.at2.resName);
570    }
571    else
572    {
573  0 b.startCol = Color.gray;
574  0 b.endCol = Color.gray;
575    }
576    }
577    }
578   
 
579  13 toggle public static Color getChargeColour(String resName)
580    {
581  13 Color result = Color.lightGray;
582  13 if ("ASP".equals(resName) || "GLU".equals(resName))
583    {
584  3 result = Color.red;
585    }
586  10 else if ("LYS".equals(resName) || "ARG".equals(resName))
587    {
588  4 result = Color.blue;
589    }
590  6 else if ("CYS".equals(resName))
591    {
592  3 result = Color.yellow;
593    }
594  13 return result;
595    }
596   
597    /**
598    * Sets the start/end colours of bonds to those of the start/end atoms
599    * according to the specified colour scheme. Note: currently only works for
600    * peptide residues.
601    *
602    * @param cs
603    */
 
604  1 toggle public void setChainColours(ColourSchemeI cs)
605    {
606  1 int index;
607  1 for (Bond b : bonds)
608    {
609  3 try
610    {
611  3 index = ResidueProperties.aa3Hash.get(b.at1.resName).intValue();
612  3 b.startCol = cs.findColour(ResidueProperties.aa[index].charAt(0), 0,
613    null, null, 0f);
614   
615  3 index = ResidueProperties.aa3Hash.get(b.at2.resName).intValue();
616  2 b.endCol = cs.findColour(ResidueProperties.aa[index].charAt(0), 0,
617    null, null, 0f);
618   
619    } catch (Exception e)
620    {
621  1 b.startCol = Color.gray;
622  1 b.endCol = Color.gray;
623    }
624    }
625    }
626   
 
627  1 toggle public void setChainColours(Color col)
628    {
629  1 for (Bond b : bonds)
630    {
631  2 b.startCol = col;
632  2 b.endCol = col;
633    }
634    }
635   
636    /**
637    * copy any sequence annotation onto the sequence mapped using the provided
638    * StructureMapping
639    *
640    * @param mapping
641    * - positional mapping between destination sequence and pdb resnum
642    * @param sqmpping
643    * - mapping between destination sequence and local chain
644    * @return
645    */
 
646  261 toggle public void transferResidueAnnotation(
647    StructureMapping mapping, jalview.datamodel.Mapping sqmpping)
648    {
649  261 SequenceI sq = mapping.getSequence();
650  261 SequenceI dsq = sq;
651  261 if (sqmpping == null)
652    {
653    // SIFTS mappings are recorded in the StructureMapping object...
654   
655  0 sqmpping = mapping.getSeqToPdbMapping();
656    }
657  261 if (sq != null)
658    {
659  520 while (dsq.getDatasetSequence() != null)
660    {
661  259 dsq = dsq.getDatasetSequence();
662    }
663    // any annotation will be transferred onto the dataset sequence
664   
665  261 if (shadow != null && shadow.getAnnotation() != null)
666    {
667    // Shadow is the structure's sequences
668  0 for (AlignmentAnnotation ana : shadow.getAnnotation())
669    {
670    // match on calcId, label and description so annotations from
671    // different structures are preserved
672  0 List<AlignmentAnnotation> transfer = sq.getAlignmentAnnotations(
673    ana.getCalcId(), ana.label, ana.description);
674  0 if (transfer == null || transfer.size() == 0)
675    {
676  0 ContactMatrixI cm = shadow.getContactMatrixFor(ana);
677  0 ana = new AlignmentAnnotation(ana);
678  0 addMetadata(ana);
679    // TODO map contact matrix under mapping
680  0 ana.liftOver(sequence, shadowMap);
681  0 ana.liftOver(dsq, sqmpping);
682  0 dsq.addAlignmentAnnotation(ana);
683  0 if (cm != null)
684    {
685  0 dsq.addContactListFor(ana, cm);
686    }
687    }
688    else
689    {
690  0 continue;
691    }
692    }
693    }
694    else
695    {
696  261 if (sequence != null && sequence.getAnnotation() != null)
697    {
698  204 for (AlignmentAnnotation ana : sequence.getAnnotation())
699    {
700    // match on calcId, label and description so annotations from
701    // different structures are preserved
702  420 List<AlignmentAnnotation> transfer = dsq
703    .getAlignmentAnnotations(ana.getCalcId(), ana.label,
704    ana.description);
705  420 if (transfer == null || transfer.size() == 0)
706    {
707  228 ContactMatrixI cm = sequence.getContactMatrixFor(ana);
708  228 ana = new AlignmentAnnotation(ana);
709  228 addMetadata(ana);
710  228 ana.liftOver(dsq, sqmpping);
711  228 dsq.addAlignmentAnnotation(ana);
712  228 if (cm != null && cm instanceof MappableContactMatrixI)
713    {
714  39 dsq.addContactListFor(ana, ((MappableContactMatrixI) cm)
715    .liftOver(dsq, sqmpping));
716    }
717    }
718    else
719    {
720  192 continue;
721    }
722    }
723    }
724    }
725  261 if (false)
726    {
727    // Useful for debugging mappings - adds annotation for mapped position
728  0 float min = -1, max = 0;
729  0 Annotation[] an = new Annotation[sq.getEnd() - sq.getStart() + 1];
730  0 for (int i = sq.getStart(), j = sq.getEnd(),
731  0 k = 0; i <= j; i++, k++)
732    {
733  0 int prn = mapping.getPDBResNum(k + 1);
734   
735  0 an[k] = new Annotation(prn);
736  0 if (min == -1)
737    {
738  0 min = k;
739  0 max = k;
740    }
741    else
742    {
743  0 if (min > k)
744    {
745  0 min = k;
746    }
747  0 else if (max < k)
748    {
749  0 max = k;
750    }
751    }
752    }
753  0 AlignmentAnnotation pdbresnumannots = new AlignmentAnnotation(
754    "PDB.RESNUM",
755    "PDB Residue Numbering for " + this.pdbid + ":" + this.id,
756    an, min, max, AlignmentAnnotation.LINE_GRAPH);
757   
758  0 sq.addAlignmentAnnotation(pdbresnumannots);
759    }
760    }
761    }
762   
 
763  228 toggle private void addMetadata(AlignmentAnnotation ana)
764    {
765  228 if (pdbid != null && !pdbid.isEmpty())
766    {
767  228 ana.setProperty(Constants.PDBID, pdbid);
768    }
769  228 if (id != null)
770    {
771  228 ana.setProperty(Constants.CHAINID, id);
772    }
773    }
774    }