}
/**
- * Returns a hashCode derived from the hashcodes of the mappings
+ * Returns a hashCode derived from the hashcodes of the mappings and fromSeq
*
* @see SequenceToSequenceMapping#hashCode()
*/
@Override
public int hashCode()
{
- return mapping.hashCode();
+ return (fromSeq == null ? 0 : fromSeq.hashCode() * 31)
+ + mapping.hashCode();
}
/**
{
return that.mapping == null;
}
- return this.mapping.equals(that.mapping);
+ // TODO: can simplify by asserting fromSeq is a dataset sequence
+ return (this.fromSeq == that.fromSeq || (this.fromSeq != null
+ && that.fromSeq != null
+ && this.fromSeq.getDatasetSequence() != null && this.fromSeq
+ .getDatasetSequence() == that.fromSeq.getDatasetSequence()))
+ && this.mapping.equals(that.mapping);
}
public SequenceI getFromSeq()
*/
public void addMap(SequenceI dnaseq, SequenceI aaseq, MapList map)
{
+ addMap(dnaseq, aaseq, map, null);
+ }
+
+ /**
+ * Adds a mapping between the dataset sequences for the associated dna and
+ * protein sequence objects
+ *
+ * @param dnaseq
+ * @param aaseq
+ * @param map
+ * @param mapFromId
+ */
+ public void addMap(SequenceI dnaseq, SequenceI aaseq, MapList map,
+ String mapFromId)
+ {
// JBPNote DEBUG! THIS !
// dnaseq.transferAnnotation(aaseq, mp);
// aaseq.transferAnnotation(dnaseq, new Mapping(map.getInverse()));
* otherwise, add a new sequence mapping
*/
Mapping mp = new Mapping(toSeq, map);
+ mp.setMappedFromId(mapFromId);
mappings.add(new SequenceToSequenceMapping(fromSeq, mp));
}
for (SequenceToSequenceMapping ssm : mappings)
{
- if (ssm.mapping.to == protein)
+ if (ssm.mapping.to == protein
+ && ssm.mapping.getMap().getFromRatio() == 3)
{
ml = ssm.mapping.map;
dnaSeq = ssm.fromSeq;
}
/**
- * Returns the first mapping found that is from 'fromSeq' to 'toSeq', or null
- * if none found
+ * Returns the first mapping found that is between 'fromSeq' and 'toSeq', or
+ * null if none found
*
* @param fromSeq
* aligned or dataset sequence
*/
public Mapping getMappingBetween(SequenceI fromSeq, SequenceI toSeq)
{
+ SequenceI dssFrom = fromSeq.getDatasetSequence() == null ? fromSeq
+ : fromSeq.getDatasetSequence();
+ SequenceI dssTo = toSeq.getDatasetSequence() == null ? toSeq : toSeq
+ .getDatasetSequence();
+
for (SequenceToSequenceMapping mapping : mappings)
{
SequenceI from = mapping.fromSeq;
SequenceI to = mapping.mapping.to;
- if ((from == fromSeq || from == fromSeq.getDatasetSequence())
- && (to == toSeq || to == toSeq.getDatasetSequence()))
+ if ((from == dssFrom && to == dssTo)
+ || (from == dssTo && to == dssFrom))
{
return mapping.mapping;
}