SequenceI[] retrieved = null;
SequenceI dss = seq.getDatasetSequence() == null ? seq : seq
.getDatasetSequence();
+ // first filter in case we are retrieving crossrefs that have already been
+ // retrieved. this happens for cases where a database record doesn't yield
+ // protein products for CDS
+ DBRefEntry[] dbrSourceSet = sourceRefs.toArray(new DBRefEntry[0]);
+ for (SequenceI sq : dataset.getSequences())
+ {
+ boolean dupeFound = false;
+ // !fromDna means we are looking only for nucleotide sequences, not
+ // protein
+ if (sq.isProtein() == fromDna)
+ {
+ for (DBRefEntry dbr : sq.getPrimaryDBRefs())
+ {
+ for (DBRefEntry found : DBRefUtils.searchRefs(dbrSourceSet, dbr))
+ {
+ sourceRefs.remove(found);
+ dupeFound = true;
+ }
+ }
+ }
+ if (dupeFound)
+ {
+ dbrSourceSet = sourceRefs.toArray(new DBRefEntry[0]);
+ }
+ }
+ if (sourceRefs.size() == 0)
+ {
+ // no more work to do! We already had all requested sequence records in
+ // the dataset.
+ return;
+ }
try
{
retrieved = sftch.getSequences(sourceRefs, !fromDna);
* </ul>
* @return true if relationship found and sequence added.
*/
- boolean searchDataset(boolean fromDna, SequenceI fromSeq,
- DBRefEntry xrf, List<SequenceI> foundSeqs, AlignedCodonFrame mappings,
+ boolean searchDataset(boolean fromDna, SequenceI fromSeq, DBRefEntry xrf,
+ List<SequenceI> foundSeqs, AlignedCodonFrame mappings,
boolean direct)
{
boolean found = false;
// }
if (!cands.isEmpty())
{
- if (!foundSeqs.contains(nxt))
+ if (foundSeqs.contains(nxt))
{
- found = true;
- foundSeqs.add(nxt);
- if (mappings != null && !direct)
+ continue;
+ }
+ found = true;
+ foundSeqs.add(nxt);
+ if (mappings != null && !direct)
+ {
+ /*
+ * if the matched sequence has mapped dbrefs to
+ * protein product / cdna, add equivalent mappings to
+ * our source sequence
+ */
+ for (DBRefEntry candidate : cands)
{
- /*
- * if the matched sequence has mapped dbrefs to
- * protein product / cdna, add equivalent mappings to
- * our source sequence
- */
- for (DBRefEntry candidate : cands)
+ Mapping mapping = candidate.getMap();
+ if (mapping != null)
{
- Mapping mapping = candidate.getMap();
- if (mapping != null)
+ MapList map = mapping.getMap();
+ if (mapping.getTo() != null
+ && map.getFromRatio() != map.getToRatio())
{
- MapList map = mapping.getMap();
- if (mapping.getTo() != null
- && map.getFromRatio() != map.getToRatio())
+ /*
+ * add a mapping, as from dna to peptide sequence
+ */
+ if (map.getFromRatio() == 3)
{
- /*
- * add a mapping, as from dna to peptide sequence
- */
- if (map.getFromRatio() == 3)
- {
- mappings.addMap(nxt, fromSeq, map);
- }
- else
- {
- mappings.addMap(nxt, fromSeq, map.getInverse());
- }
+ mappings.addMap(nxt, fromSeq, map);
+ }
+ else
+ {
+ mappings.addMap(nxt, fromSeq, map.getInverse());
}
}
}