import jalview.datamodel.DBRefSource;
import jalview.datamodel.Mapping;
import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.util.DBRefUtils;
import jalview.ws.SequenceFetcher;
*/
public class CrossRef
{
+ /*
+ * A sub-class that ignores Parent attribute when comparing sequence
+ * features. This avoids 'duplicate' CDS features that only
+ * differ in their parent Transcript ids.
+ */
+ class MySequenceFeature extends SequenceFeature
+ {
+ private SequenceFeature feat;
+
+ MySequenceFeature(SequenceFeature sf)
+ {
+ this.feat = sf;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ return feat.equals(o, true);
+ }
+ }
+
/**
* Select just the DNA or protein references for a protein or dna sequence
*
+ seq.getName());
e.printStackTrace();
}
+
if (retrieved != null)
{
+ List<SequenceFeature> copiedFeatures = new ArrayList<SequenceFeature>();
+ CrossRef me = new CrossRef();
for (int rs = 0; rs < retrieved.length; rs++)
{
// TODO: examine each sequence for 'redundancy'
&& mappedrg.getSequenceAsString().equals(
loc.getSequenceAsString()))
{
- System.err
- .println("Mapping updated for retrieved crossreference");
+ String msg = "Mapping updated from "
+ + ms.getName()
+ + " to retrieved crossreference "
+ + dss.getName();
+ System.out.println(msg);
// method to update all refs of existing To on
// retrieved sequence with dss and merge any props
// on To onto dss.
map.setTo(dss);
+ /*
+ * copy sequence features as well, avoiding
+ * duplication (e.g. from 2 transcripts)
+ */
+ SequenceFeature[] sfs = ms
+ .getSequenceFeatures();
+ if (sfs != null)
+ {
+ for (SequenceFeature feat : sfs)
+ {
+ /*
+ * we override the equality test here (but not
+ * elsewhere) to ignore Parent attribute
+ * TODO not quite working yet!
+ */
+ if (!copiedFeatures
+ .contains(me.new MySequenceFeature(
+ feat)))
+ {
+ dss.addSequenceFeature(feat);
+ copiedFeatures.add(feat);
+ }
+ }
+ }
+ cf.addMap(retrieved[rs].getDatasetSequence(),
+ dss, map.getMap());
}
} catch (Exception e)
{