From 90cf1b4dbeb37554fd4b654c1da523f5791383e4 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 18 Feb 2020 18:38:12 +0000 Subject: [PATCH] =?utf8?q?JAL-3529=20attempt=20to=20guess=20database=20for=20?= =?utf8?q?a=20sequence=E2=80=99s=20AC=20record=20based=20on=20the=20sequence?= =?utf8?q?=20type=20if=20the=20alignment=20had=20no=20PFAM=20or=20RFAM=20acc?= =?utf8?q?ession?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/io/StockholmFile.java | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/jalview/io/StockholmFile.java b/src/jalview/io/StockholmFile.java index b9f1274..4697262 100644 --- a/src/jalview/io/StockholmFile.java +++ b/src/jalview/io/StockholmFile.java @@ -334,17 +334,14 @@ public class StockholmFile extends AlignFile if (accAnnotations != null && accAnnotations.containsKey("AC")) { - if (dbsource != null) + String dbr = (String) accAnnotations.get("AC"); + if (dbr != null) { - 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); - - } + // we could get very clever here - but for now - just try to + // guess accession type from type of sequence, 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 ? @@ -760,6 +757,12 @@ public class StockholmFile extends AlignFile st = -1; } } + if (dbsource == null) + { + // make up an origin based on whether the sequence looks like it is nucleotide + // or protein + dbsource = (seqO.isProtein()) ? "PFAM" : "RFAM"; + } if (dbsource.equals("PFAM")) { seqdb = "UNIPROT"; @@ -952,9 +955,10 @@ public class StockholmFile extends AlignFile int maxid = 0; int in = 0; Hashtable dataRef = null; + boolean isAA = s[in].isProtein(); while ((in < s.length) && (s[in] != null)) { - boolean isAA = s[in].isProtein(); + String tmp = printId(s[in], jvSuffix); max = Math.max(max, s[in].getLength()); @@ -1023,7 +1027,8 @@ public class StockholmFile extends AlignFile String type = (String) dataRef.remove(idd); out.append(new Format("%-" + (maxid - 2) + "s") .form("#=GS " + idd.toString() + " ")); - if (type.contains("PFAM") || type.contains("RFAM")) + if (isAA && type.contains("UNIPROT") + || (!isAA && type.contains("EMBL"))) { out.append(" AC " + type.substring(type.indexOf(";") + 1)); -- 1.7.10.2