{
/*
* Map will hold, for each aligned column position, a map of
- * {unalignedSequence, sequenceCharacter} at that position.
+ * {unalignedSequence, characterPerSequence} at that position.
* TreeMap keeps the entries in ascending column order.
*/
Map<Integer, Map<SequenceI, Character>> map = new TreeMap<Integer, Map<SequenceI, Character>>();
/*
- * r any sequences that have no mapping so can't be realigned
+ * record any sequences that have no mapping so can't be realigned
*/
unmapped.addAll(unaligned.getSequences());
return false;
}
+ /*
+ * invert mapping if it is from unaligned to aligned sequence
+ */
+ if (seqMap.getTo() == fromSeq.getDatasetSequence())
+ {
+ seqMap = new Mapping(seq.getDatasetSequence(), seqMap.getMap()
+ .getInverse());
+ }
+
char[] fromChars = fromSeq.getSequence();
int toStart = seq.getStart();
char[] toChars = seq.getSequence();
* of the next character of the mapped-to sequence; stop when all
* the characters of the range have been counted
*/
- while (mappedCharPos <= range[1])
+ while (mappedCharPos <= range[1] && fromCol <= fromChars.length
+ && fromCol >= 0)
{
if (!Comparison.isGap(fromChars[fromCol - 1]))
{
{
ASequenceFetcher sftch = SequenceFetcherFactory.getSequenceFetcher();
SequenceI[] retrieved = null;
- SequenceI dss = null;
+ SequenceI dss = seq.getDatasetSequence() == null ? seq : seq
+ .getDatasetSequence();
try
{
retrieved = sftch.getSequences(sourceRefs, !fromDna);
}
/**
- * Returns the first mapping found that is from 'fromSeq' to 'toSeq', or null
+ * Returns the first mapping found that is between 'fromSeq' and 'toSeq', or null
* if none found
*
* @param fromSeq
*/
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;
}
AlignmentI copyAlignment = null;
final SequenceI[] sequenceSelection = AlignFrame.this.viewport
.getSequenceSelection();
- // List<AlignedCodonFrame> cf = xrefs.getCodonFrames();
boolean copyAlignmentIsAligned = false;
if (dna)
{
/**
* Returns the (possibly empty) list of those supplied dbrefs which have the
- * specified source databse
+ * specified source database, with a case-insensitive match of source name
*
* @param dbRefs
* @param source
{
for (DBRefEntry dbref : dbRefs)
{
- if (source.equals(dbref.getSource()))
+ if (source.equalsIgnoreCase(dbref.getSource()))
{
matches.add(dbref);
}
// becomes null if the alignment window was closed before the alignment
// job finished.
AlignmentI copyComplement = new Alignment(complement);
+ // todo should this be done by copy constructor?
+ copyComplement.setGapCharacter(complement.getGapCharacter());
+ // share the same dataset (and the mappings it holds)
+ copyComplement.setDataset(complement.getDataset());
copyComplement.alignAs(al);
if (copyComplement.getHeight() > 0)
{