+ /**
+ * 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);
+ }
+ }
+ }
+