List<SequenceI> rseqs;
/**
- * mappings constructed
- */
- AlignedCodonFrame cf;
-
- /**
* Constructor
*
* @param seqs
{
rseqs = new ArrayList<SequenceI>();
- cf = new AlignedCodonFrame();
+ AlignedCodonFrame cf = new AlignedCodonFrame();
matcher = new SequenceIdMatcher(
dataset.getSequences());
* but findInDataset() matches ENSP when looking for Uniprot...
*/
SequenceI matchInDataset = findInDataset(xref);
+ if (matchInDataset != null && xref.getMap().getTo() != null
+ && matchInDataset != xref.getMap().getTo())
+ {
+ System.err
+ .println("Implementation problem (reopen JAL-2154): CrossRef.findInDataset seems to have recovered a different sequence than the one explicitly mapped for xref."
+ + "Found:"
+ + matchInDataset
+ + "\nExpected:"
+ + xref.getMap().getTo()
+ + "\nFor xref:"
+ + xref);
+ }
/*matcher.findIdMatch(mappedTo);*/
if (matchInDataset != null)
{
if (!rseqs.contains(matchInDataset))
{
rseqs.add(matchInDataset);
+ // need to try harder to only add unique mappings
+ if (xref.getMap().getMap().isTripletMap()
+ && dataset.getMapping(seq, matchInDataset) == null
+ && cf.getMappingBetween(seq, matchInDataset) == null)
+ {
+ // materialise a mapping for highlighting between these sequences
+ if (fromDna)
+ {
+ cf.addMap(dss, matchInDataset, xref.getMap().getMap(), xref.getMap().getMappedFromId());
+ } else {
+ cf.addMap(matchInDataset, dss, xref.getMap().getMap().getInverse(), xref.getMap().getMappedFromId());
+ }
+ }
}
refIterator.remove();
continue;
}
+ // TODO: need to determine if this should be a deriveSequence
SequenceI rsq = new Sequence(mappedTo);
rseqs.add(rsq);
- if (xref.getMap().getMap().getFromRatio() != xref.getMap()
- .getMap().getToRatio())
+ if (xref.getMap().getMap().isTripletMap())
{
// get sense of map correct for adding to product alignment.
if (fromDna)
*/
if (!sourceRefs.isEmpty())
{
- retrieveCrossRef(sourceRefs, seq, xrfs, fromDna);
+ retrieveCrossRef(sourceRefs, seq, xrfs, fromDna, cf);
}
}
}
private void retrieveCrossRef(List<DBRefEntry> sourceRefs, SequenceI seq,
- DBRefEntry[] xrfs, boolean fromDna)
+ DBRefEntry[] xrfs, boolean fromDna, AlignedCodonFrame cf)
{
ASequenceFetcher sftch = SequenceFetcherFactory.getSequenceFetcher();
SequenceI[] retrieved = null;
}
else
{
+ dataset.addSequence(map.getTo());
matcher.add(map.getTo());
}
try
DBRefEntry xref, AlignedCodonFrame mappings, boolean fromDna)
{
MapList mapping = null;
-
+ SequenceI dsmapFrom = mapFrom.getDatasetSequence() == null ? mapFrom
+ : mapFrom.getDatasetSequence();
+ SequenceI dsmapTo = mapFrom.getDatasetSequence() == null ? mapTo
+ : mapTo.getDatasetSequence();
/*
- * look for a reverse mapping, if found make its inverse
+ * look for a reverse mapping, if found make its inverse.
+ * Note - we do this on dataset sequences only.
*/
- if (mapTo.getDBRefs() != null)
+ if (dsmapTo.getDBRefs() != null)
{
- for (DBRefEntry dbref : mapTo.getDBRefs())
+ for (DBRefEntry dbref : dsmapTo.getDBRefs())
{
String name = dbref.getSource() + "|" + dbref.getAccessionId();
- if (dbref.hasMap() && mapFrom.getName().startsWith(name))
+ if (dbref.hasMap() && dsmapFrom.getName().startsWith(name))
{
/*
* looks like we've found a map from 'mapTo' to 'mapFrom'
* - invert it to make the mapping the other way
*/
MapList reverse = dbref.getMap().getMap().getInverse();
- xref.setMap(new Mapping(mapTo, reverse));
- mappings.addMap(mapFrom, mapTo, reverse);
+ xref.setMap(new Mapping(dsmapTo, reverse));
+ mappings.addMap(mapFrom, dsmapTo, reverse);
return true;
}
}