/**
* Convenience method to return the first aligned sequence in the given
- * alignment whose dataset has a mapping with the given dataset sequence.
+ * alignment whose dataset has a mapping with the given (aligned or dataset)
+ * sequence.
*
* @param seq
*
*/
for (SequenceToSequenceMapping ssm : mappings)
{
- if (ssm.fromSeq == seq)
+ if (ssm.fromSeq == seq || ssm.fromSeq == seq.getDatasetSequence())
{
for (SequenceI sourceAligned : al.getSequences())
{
*/
for (SequenceToSequenceMapping ssm : mappings)
{
- if (ssm.mapping.to == seq)
+ if (ssm.mapping.to == seq
+ || ssm.mapping.to == seq.getDatasetSequence())
{
for (SequenceI sourceAligned : al.getSequences())
{
}
/**
- * Returns any mappings found which are to (or from) the given sequence, and
- * to distinct sequences.
+ * Returns any mappings found which are from the given sequence, and to
+ * distinct sequences.
*
* @param seq
* @return
*/
- public List<Mapping> getMappingsForSequence(SequenceI seq)
+ public List<Mapping> getMappingsFromSequence(SequenceI seq)
{
List<Mapping> result = new ArrayList<Mapping>();
List<SequenceI> related = new ArrayList<SequenceI>();
for (SequenceToSequenceMapping ssm : mappings)
{
final Mapping mapping = ssm.mapping;
- if (ssm.fromSeq == seqDs || mapping.to == seqDs)
+ if (ssm.fromSeq == seqDs)
{
if (!related.contains(mapping.to))
{
{
return mappings.isEmpty();
}
+
+ /**
+ * Method for debug / inspection purposes only, may change in future
+ */
+ @Override
+ public String toString()
+ {
+ return mappings == null ? "null" : mappings.toString();
+ }
+
+ /**
+ * Returns the first mapping found that is from 'fromSeq' to 'toSeq', or null
+ * if none found
+ *
+ * @param fromSeq
+ * aligned or dataset sequence
+ * @param toSeq
+ * aligned or dataset sequence
+ * @return
+ */
+ public Mapping getMappingBetween(SequenceI fromSeq, SequenceI toSeq)
+ {
+ for (SequenceToSequenceMapping mapping : mappings)
+ {
+ SequenceI from = mapping.fromSeq;
+ SequenceI to = mapping.mapping.to;
+ if ((from == fromSeq || from == fromSeq.getDatasetSequence())
+ && (to == toSeq || to == toSeq.getDatasetSequence()))
+ {
+ return mapping.mapping;
+ }
+ }
+ return null;
+ }
}