+ * Used by file parsers to generate DBRefs from annotation within file (eg + * Stockholm) * * @param dbname * @param version * @param acn * @param seq - * where to anotate with reference + * where to annotate with reference * @return parsed version of entry that was added to seq (if any) */ public static DBRefEntry parseToDbRef(SequenceI seq, String dbname, @@ -410,19 +424,25 @@ public class DBRefUtils DBRefEntry ref = null; if (dbname != null) { - String locsrc = jalview.util.DBRefUtils.getCanonicalName(dbname); - if (locsrc.equals(jalview.datamodel.DBRefSource.PDB)) + String locsrc = DBRefUtils.getCanonicalName(dbname); + if (locsrc.equals(DBRefSource.PDB)) { - // check for chaincode and mapping - // PFAM style stockhom PDB citation - com.stevesoft.pat.Regex r = new com.stevesoft.pat.Regex( - "([0-9][0-9A-Za-z]{3})\\s*(.?)\\s*;([0-9]+)-([0-9]+)"); + /* + * Check for PFAM style stockhom PDB accession id citation e.g. + * "1WRI A; 7-80;" + */ + Regex r = new com.stevesoft.pat.Regex( + "([0-9][0-9A-Za-z]{3})\\s*(.?)\\s*;\\s*([0-9]+)-([0-9]+)"); if (r.search(acn.trim())) { String pdbid = r.stringMatched(1); String chaincode = r.stringMatched(2); - String mapstart = r.stringMatched(3); - String mapend = r.stringMatched(4); + if (chaincode==null) + { + chaincode = " "; + } + // String mapstart = r.stringMatched(3); + // String mapend = r.stringMatched(4); if (chaincode.equals(" ")) { chaincode = "_"; @@ -431,7 +451,13 @@ public class DBRefUtils ref = new DBRefEntry(locsrc, version, pdbid + chaincode); PDBEntry pdbr = new PDBEntry(); pdbr.setId(pdbid); + pdbr.setType(PDBEntry.Type.PDB); + pdbr.setProperty(new Hashtable()); + pdbr.setChainCode(chaincode); + // pdbr.getProperty().put("CHAIN", chaincode); seq.addPDBId(pdbr); + } else { + System.err.println("Malformed PDB DR line:"+acn); } } else @@ -447,4 +473,36 @@ public class DBRefUtils return ref; } + /** + * Extract valid accession strings from a query string. Used by the + * SequenceFetcher and DBRefFetcher to create valid accession strings from an + * ID string for database sources with a Regex validation field. + * + * @param proxy + * @param q + * @return q if proxy.getAccessionValidator()==null, otherwise the matched + * region or the first subgroup match from the matched region + */ + public static String processQueryToAccessionFor(DbSourceProxy proxy, + String q) + { + if (proxy.getAccessionValidator() != null) + { + Regex vgr = proxy.getAccessionValidator(); + vgr.search(q); + if (vgr.numSubs() > 0) + { + return (vgr.stringMatched(1)); + } + else + { + return (vgr.stringMatched()); + } + } + else + { + return (q); + } + } + }