\r
/**\r
* This class is supposed to parse a Stockholm format file into Jalview\r
- * \r
+ * There are TODOs in this class: we do not know what the database source and\r
+ * version is for the file when parsing the #GS= AC tag which associates accessions\r
+ * with sequences. \r
+ * Database references are also not parsed correctly: a separate reference string\r
+ * parser must be added to parse the database reference form into Jalview's local\r
+ * representation.\r
* @author bsb at sanger.ac.uk\r
- * @version 0.3\r
+ * @version 0.3 + jalview mods\r
+ * \r
*/\r
public class StockholmFile extends AlignFile\r
{\r
{\r
String src = dbr.substring(0, dbr.indexOf(";"));\r
String acn = dbr.substring(dbr.indexOf(";") + 1);\r
- DBRefEntry dbref = new DBRefEntry(jalview.util.DBRefUtils\r
- .getCanonicalName(src), acn, "");\r
- seqO.addDBRef(dbref);\r
+ jalview.util.DBRefUtils.parseToDbRef(seqO, src, "0", acn);\r
+ //seqO.addDBRef(dbref);\r
}\r
}\r
Hashtable features = null;\r
return false;
}
};
+ /**
+ * 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
+ * @return parsed version of entry that was added to seq (if any)
+ */
+ public static DBRefEntry parseToDbRef(SequenceI seq, String dbname, String version,
+ String acn)
+ {
+ DBRefEntry ref = null;
+ if (dbname!=null)
+ {
+ String locsrc = jalview.util.DBRefUtils
+ .getCanonicalName(dbname);
+ if (locsrc.equals(jalview.datamodel.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]+)");
+ 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.equals(" "))
+ {
+ chaincode = "_";
+ }
+ // construct pdb ref.
+ ref = new DBRefEntry(locsrc, version, pdbid+chaincode);
+ PDBEntry pdbr = new PDBEntry();
+ pdbr.setId(pdbid);
+ seq.addPDBId(pdbr);
+ }
+ } else {
+ // default:
+ ref = new DBRefEntry(locsrc, version, acn);
+ }
+ }
+ if (ref!=null)
+ {
+ seq.addDBRef(ref);
+ }
+ return ref;
+ }
}