public static SearchResults buildSearchResults(SequenceI seq, int index,
Set<AlignedCodonFrame> seqmappings)
{
- SearchResults results;
- results = new SearchResults();
+ SearchResults results = new SearchResults();
+ addSearchResults(results, seq, index, seqmappings);
+ return results;
+ }
+
+ /**
+ * Adds entries to a SearchResults object describing the mapped region
+ * corresponding to the specified sequence position.
+ *
+ * @param results
+ * @param seq
+ * @param index
+ * @param seqmappings
+ */
+ public static void addSearchResults(SearchResults results, SequenceI seq,
+ int index, Set<AlignedCodonFrame> seqmappings)
+ {
if (index >= seq.getStart() && index <= seq.getEnd())
{
for (AlignedCodonFrame acf : seqmappings)
acf.markMappedRegion(seq, index, results);
}
}
- return results;
}
/**
}
return result;
}
+
+ /**
+ * Returns a list of any mappings that are from or to the given (aligned or
+ * dataset) sequence.
+ *
+ * @param sequence
+ * @param mappings
+ * @return
+ */
+ public static List<AlignedCodonFrame> findMappingsForSequence(
+ SequenceI sequence, Set<AlignedCodonFrame> mappings)
+ {
+ List<AlignedCodonFrame> result = new ArrayList<AlignedCodonFrame>();
+ if (sequence == null || mappings == null)
+ {
+ return result;
+ }
+ for (AlignedCodonFrame mapping : mappings) {
+ if (mapping.involvesSequence(sequence)) {
+ result.add(mapping);
+ }
+ }
+ return result;
+ }
}