+ String accId = querySeq.getName();
+ try
+ {
+ AlignmentI protein = new EnsemblProtein(getDomain())
+ .getSequenceRecords(accId);
+ if (protein == null || protein.getHeight() == 0)
+ {
+ System.out.println("No protein product found for " + accId);
+ return;
+ }
+ SequenceI proteinSeq = protein.getSequenceAt(0);
+
+ /*
+ * need dataset sequences (to be the subject of mappings)
+ */
+ proteinSeq.createDatasetSequence();
+ querySeq.createDatasetSequence();
+
+ MapList mapList = AlignmentUtils
+ .mapCdsToProtein(querySeq, proteinSeq);
+ if (mapList != null)
+ {
+ // clunky: ensure Uniprot xref if we have one is on mapped sequence
+ SequenceI ds = proteinSeq.getDatasetSequence();
+ // TODO: Verify ensp primary ref is on proteinSeq.getDatasetSequence()
+ Mapping map = new Mapping(ds, mapList);
+ DBRefEntry dbr = new DBRefEntry(getDbSource(),
+ getEnsemblDataVersion(), proteinSeq.getName(), map);
+ querySeq.getDatasetSequence().addDBRef(dbr);
+ DBRefEntry[] uprots = DBRefUtils.selectRefs(ds.getDBRefs(),
+ new String[] { DBRefSource.UNIPROT });
+ DBRefEntry[] upxrefs = DBRefUtils.selectRefs(querySeq.getDBRefs(),
+ new String[] { DBRefSource.UNIPROT });
+ if (uprots != null)
+ {
+ for (DBRefEntry up : uprots)
+ {
+ // locate local uniprot ref and map
+ List<DBRefEntry> upx = DBRefUtils.searchRefs(upxrefs,
+ up.getAccessionId());
+ DBRefEntry upxref;
+ if (upx.size() != 0)
+ {
+ upxref = upx.get(0);
+
+ if (upx.size() > 1)
+ {
+ Cache.log
+ .warn("Implementation issue - multiple uniprot acc on product sequence.");
+ }
+ }
+ else
+ {
+ upxref = new DBRefEntry(DBRefSource.UNIPROT,
+ getEnsemblDataVersion(), up.getAccessionId());
+ }
+
+ Mapping newMap = new Mapping(ds, mapList);
+ upxref.setVersion(getEnsemblDataVersion());
+ upxref.setMap(newMap);
+ if (upx.size() == 0)
+ {
+ // add the new uniprot ref
+ querySeq.getDatasetSequence().addDBRef(upxref);
+ }
+
+ }
+ }
+
+ /*
+ * copy exon features to protein, compute peptide variants from dna
+ * variants and add as features on the protein sequence ta-da
+ */
+ AlignmentUtils
+ .computeProteinFeatures(querySeq, proteinSeq, mapList);
+ }
+ } catch (Exception e)
+ {
+ System.err
+ .println(String.format("Error retrieving protein for %s: %s",
+ accId, e.getMessage()));
+ }