dna.addSequenceFeature(sf);
}
}
- // add dbRefs to sequence
+
+ /*
+ * add dbRefs to sequence, and mappings for Uniprot xrefs
+ */
if (feature.dbRefs != null)
{
- boolean productMapped = false;
+ boolean mappingUsed = false;
for (DBRefEntry ref : feature.dbRefs)
{
ref.setSource(DBRefUtils.getCanonicalName(ref.getSource()));
- // Hard code the kind of protein product accessions that EMBL cite
if (ref.getSource().equals(DBRefSource.UNIPROT))
{
- String refSeqName = DBRefSource.UNIPROT + "|"
+ String proteinSeqName = DBRefSource.UNIPROT + "|"
+ ref.getAccessionId();
- ref.setMap(map);
if (map != null && map.getTo() != null)
{
- // if (!productMapped)
- // {
- // map.getTo().setName(refSeqName);
- // map.getTo().addDBRef(
- // new DBRefEntry(ref.getSource(), ref.getVersion(), ref
- // .getAccessionId())); // don't copy map over.
- // // if (map.getTo().getName().startsWith(prid))
- // productMapped = true;
- // }
- // else
- // {
+ if (mappingUsed)
+ {
/*
- * an alternate UNIPROT product for CDS - same mapping
- * but to a sequence with a different name
+ * two or more Uniprot xrefs for the same CDS -
+ * each needs a distinct Mapping (as to a different sequence)
*/
- SequenceI newSeq = matcher.findIdMatch(refSeqName);
- if (newSeq == null)
- {
- newSeq = new Sequence(refSeqName, map.getTo()
+ map = new Mapping(map);
+ }
+ mappingUsed = true;
+
+ /*
+ * try to locate the protein mapped to (possibly by a
+ * previous CDS feature)
+ */
+ SequenceI proteinSeq = matcher.findIdMatch(proteinSeqName);
+ if (proteinSeq == null)
+ {
+ proteinSeq = new Sequence(proteinSeqName,
+ product
.getSequenceAsString());
- matcher.add(newSeq);
- peptides.add(newSeq);
- }
- Mapping newMap = new Mapping(newSeq, map.getMap());
- ref.setMap(newMap);
- // }
+ matcher.add(proteinSeq);
+ peptides.add(proteinSeq);
+ }
+ map.setTo(proteinSeq);
+ map.getTo().addDBRef(
+ new DBRefEntry(ref.getSource(), ref.getVersion(), ref
+ .getAccessionId()));
+ ref.setMap(map);
}
noProteinDbref = false;
}