+ for (Integer seqPos : mapping.keySet())
+ {
+ if (pdbResNum == getPDBResNum(seqPos))
+ {
+ return seqPos;
+ }
+ }
+ return UNASSIGNED_VALUE;
+ }
+
+ /**
+ * transfer a copy of an alignment annotation row in the PDB chain coordinate
+ * system onto the mapped sequence
+ *
+ * @param ana
+ * @return the copy that was remapped to the mapped sequence
+ * @note this method will create a copy and add it to the dataset sequence for
+ * the mapped sequence as well as the mapped sequence (if it is not a
+ * dataset sequence).
+ */
+ public AlignmentAnnotation transfer(AlignmentAnnotation ana)
+ {
+ AlignmentAnnotation ala_copy = new AlignmentAnnotation(ana);
+ SequenceI ds = sequence;
+ while (ds.getDatasetSequence() != null)
+ {
+ ds = ds.getDatasetSequence();
+ }
+ // need to relocate annotation from pdb coordinates to local sequence
+ // -1,-1 doesn't look at pdbresnum but fails to remap sequence positions...
+
+ ala_copy.remap(ds, mapping, -1, -1, 0);
+ ds.addAlignmentAnnotation(ala_copy);
+ if (ds != sequence)
+ {
+ // mapping wasn't to an original dataset sequence, so we make a copy on
+ // the mapped sequence too
+ ala_copy = new AlignmentAnnotation(ala_copy);
+ sequence.addAlignmentAnnotation(ala_copy);
+ }
+ return ala_copy;
+ }
+
+ public String getMappingDetailsOutput()
+ {
+ return mappingDetails;
+ }
+
+ public HashMap<Integer, int[]> getMapping()
+ {
+ return mapping;
+ }
+
+ public Mapping getSeqToPdbMapping()
+ {
+ return seqToPdbMapping;
+ }
+
+ /**
+ * A hash function that satisfies the contract that if two mappings are
+ * equal(), they have the same hashCode
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((mappingDetails == null) ? 0 : mappingDetails.hashCode());
+ result = prime * result
+ + ((pdbchain == null) ? 0 : pdbchain.hashCode());
+ result = prime * result + ((pdbfile == null) ? 0 : pdbfile.hashCode());
+ result = prime * result + ((pdbid == null) ? 0 : pdbid.hashCode());
+ result = prime * result
+ + ((seqToPdbMapping == null) ? 0 : seqToPdbMapping.hashCode());
+ result = prime * result
+ + ((sequence == null) ? 0 : sequence.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ StructureMapping other = (StructureMapping) obj;
+ if (mappingDetails == null)
+ {
+ if (other.mappingDetails != null)
+ {
+ return false;
+ }
+ }
+ else if (!mappingDetails.equals(other.mappingDetails))
+ {
+ return false;
+ }
+ if (pdbchain == null)