// End of the alignment, pass stuff back
this.noSeqs = seqs.size();
- String propety = null;
+ String seqdb,dbsource = null;
Regex pf = new Regex("PF[0-9]{5}(.*)"); // Finds AC for Pfam
Regex rf = new Regex("RF[0-9]{5}(.*)"); // Finds AC for Rfam
if (getAlignmentProperty("AC") != null)
String dbType = getAlignmentProperty("AC").toString();
if (pf.search(dbType))
{
- propety = "PFAM";
+ // PFAM Alignment - so references are typically from Uniprot
+ dbsource = "PFAM";
}
else if (rf.search(dbType))
{
- propety = "RFAM";
+ dbsource = "RFAM";
}
}
// logger.debug("Number of sequences: " + this.noSeqs);
}
}
- if (accAnnotations != null && accAnnotations.containsKey("AC")
- && propety != null)
+ if (accAnnotations != null && accAnnotations.containsKey("AC"))
{
- String dbr = (String) accAnnotations.get("AC");
- if (dbr != null)
+ if (dbsource != null)
{
- String src = propety;
- String acn = dbr.toString();
- jalview.util.DBRefUtils.parseToDbRef(seqO, src, "0", acn);
- }
+ String dbr = (String) accAnnotations.get("AC");
+ if (dbr != null)
+ {
+ // we could get very clever here - but for now - just try to guess accession type from source of alignment plus structure of accession
+ guessDatabaseFor(seqO, dbr, dbsource);
+
+ }
+ }
+ // else - do what ? add the data anyway and prompt the user to specify what references these are ?
}
Hashtable features = null;
}
}
+ /**
+ * Demangle an accession string and guess the originating sequence database for a given sequence
+ * @param seqO sequence to be annotated
+ * @param dbr Accession string for sequence
+ * @param dbsource source database for alignment (PFAM or RFAM)
+ */
+ private void guessDatabaseFor(Sequence seqO, String dbr, String dbsource)
+ {
+ DBRefEntry dbrf=null;
+ List<DBRefEntry> dbrs=new ArrayList<DBRefEntry>();
+ String seqdb="Unknown",sdbac=""+dbr;
+ int st=-1,en=-1,p;
+ if ((st=sdbac.indexOf("/"))>-1)
+ {
+ String num,range=sdbac.substring(st+1);
+ sdbac = sdbac.substring(0,st);
+ if ((p=range.indexOf("-"))>-1)
+ {
+ p++;
+ if (p<range.length())
+ {
+ num = range.substring(p).trim();
+ try {
+ en = Integer.parseInt(num);
+ } catch (NumberFormatException x)
+ {
+ // could warn here that index is invalid
+ en = -1;
+ }
+ }
+ } else {
+ p=range.length();
+ }
+ num=range.substring(0,p).trim();
+ try {
+ st = Integer.parseInt(num);
+ } catch (NumberFormatException x)
+ {
+ // could warn here that index is invalid
+ st = -1;
+ }
+ }
+ if (dbsource.equals("PFAM")) {
+ seqdb = "UNIPROT";
+ if (sdbac.indexOf(".")>-1)
+ {
+ // strip of last subdomain
+ sdbac = sdbac.substring(0,sdbac.indexOf("."));
+ dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, seqdb, dbsource, sdbac);
+ if (dbrf!=null)
+ {
+ dbrs.add(dbrf);
+ }
+ }
+ dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, dbsource, dbsource, dbr);
+ if (dbr!=null)
+ {
+ dbrs.add(dbrf);
+ }
+ } else {
+ seqdb = "EMBL"; // total guess - could be ENA, or something else these days
+ if (sdbac.indexOf(".")>-1)
+ {
+ // strip off last subdomain
+ sdbac = sdbac.substring(0,sdbac.indexOf("."));
+ dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, seqdb, dbsource, sdbac);
+ if (dbrf!=null)
+ {
+ dbrs.add(dbrf);
+ }
+ }
+
+ dbrf = jalview.util.DBRefUtils.parseToDbRef(seqO, dbsource, dbsource, dbr);
+ if (dbrf!=null)
+ {
+ dbrs.add(dbrf);
+ }
+ }
+ if (st!=-1 && en!=-1)
+ {
+ for (DBRefEntry d:dbrs)
+ {
+ jalview.util.MapList mp = new jalview.util.MapList(new int[] { seqO.getStart(),seqO.getEnd()},new int[] { st,en},1,1);
+ jalview.datamodel.Mapping mping = new Mapping(mp);
+ d.setMap(mping);
+ }
+ }
+ }
+
protected static AlignmentAnnotation parseAnnotationRow(
Vector annotation, String label, String annots)
{