1 package jalview.ws.dbsources;
4 import java.io.IOException;
6 import com.stevesoft.pat.Regex;
8 import jalview.bin.Cache;
9 import jalview.datamodel.Alignment;
10 import jalview.datamodel.AlignmentI;
11 import jalview.datamodel.SequenceI;
12 import jalview.io.DataSourceType;
13 import jalview.io.EmblFlatFile;
14 import jalview.io.FileParse;
15 import jalview.ws.ebi.EBIFetchClient;
18 * A class that does partial parsing of an EMBL flatfile.
23 public abstract class EmblFlatfileSource extends EbiFileRetrievedProxy
25 private static final Regex ACCESSION_REGEX = new Regex("^[A-Z]+[0-9]+");
28 public String getDbVersion()
34 public String getAccessionSeparator()
40 public Regex getAccessionValidator()
42 return ACCESSION_REGEX;
46 public boolean isValidReference(String accession)
48 if (accession == null || accession.length() < 2)
52 return getAccessionValidator().search(accession);
56 public AlignmentI getSequenceRecords(String queries) throws Exception
67 protected AlignmentI getEmblSequenceRecords(String dbName, String query)
71 EBIFetchClient dbFetch = new EBIFetchClient();
75 reply = dbFetch.fetchDataAsFile(
76 dbName.toLowerCase() + ":" + query.trim(), null, "gz");
81 String.format("EBI EMBL retrieval failed for %s:%s",
82 dbName.toLowerCase(), query.trim()),
85 return getEmblSequenceRecords(dbName, query, reply);
88 private AlignmentI getEmblSequenceRecords(String dbName, String query,
89 File reply) throws IOException
93 if (reply != null && reply.exists())
95 file = reply.getAbsolutePath();
96 FileParse fp = new FileParse(file, DataSourceType.FILE);
97 EmblFlatFile emblParser = new EmblFlatFile(fp, getDbSource());
99 SequenceI[] seqs = emblParser.getSeqsAsArray();
102 al = new Alignment(seqs);
108 "No record found for '" + dbName + ":" + query + "'");
117 public boolean isDnaCoding()