package jalview.ext.ensembl;
+import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.DBRefSource;
import jalview.datamodel.SequenceI;
import jalview.exceptions.JalviewException;
import jalview.ext.ensembl.SeqFetcher.EnsemblSeqType;
import jalview.io.FastaFile;
import jalview.io.FileParse;
import jalview.util.DBRefUtils;
-import jalview.ws.seqfetcher.DbSourceProxy;
import jalview.ws.seqfetcher.DbSourceProxyImpl;
import java.util.ArrayList;
import com.stevesoft.pat.Regex;
-public abstract class EnsemblSeqProxy extends DbSourceProxyImpl implements
- DbSourceProxy
+public abstract class EnsemblSeqProxy extends DbSourceProxyImpl
{
SeqFetcher sf;
- public EnsemblSeqProxy() throws Exception
+ public EnsemblSeqProxy()
{
sf = new SeqFetcher();
- addDbSourceProperty(DBRefSource.MULTIACC);
- addDbSourceProperty(DBRefSource.SEQDB);
- // decide whether these need to be filtered according to return type
- addDbSourceProperty(DBRefSource.PROTSEQDB);
- addDbSourceProperty(DBRefSource.DNACODINGSEQDB);
- addDbSourceProperty(DBRefSource.DNASEQDB);
}
@Override
return new Regex("((ENSP|ENST|ENSG|CCDS)[0-9.]{3,})");
}
+ /**
+ * Default test query is a transcript
+ */
@Override
public String getTestQuery()
{
- return "ENSP00000288602";
+ return "ENST00000288602";
}
@Override
List<String> tids, ids = new ArrayList<String>();
tids = Arrays.asList(queries.split(" +"));
AlignmentI rtn = null;
- for (int v = 0, vSize = tids.size(); v < vSize; v += 50)
+
+ /*
+ * execute queries, if necessary in batches of the
+ * maximum allowed number of ids
+ */
+ int maxQueryCount = getMaximumQueryCount();
+ for (int v = 0, vSize = tids.size(); v < vSize; v += maxQueryCount)
{
- int p = v + 50;
- if (p > vSize)
- {
- p = vSize;
- }
- ;
+ int p = Math.min(vSize, v + maxQueryCount);
ids = tids.subList(v, p);
try
{
}
if (fr.getSeqs().size() > 0)
{
- AlignmentI seqal = new jalview.datamodel.Alignment(
+ AlignmentI seqal = new Alignment(
fr.getSeqsAsArray());
for (SequenceI sq:seqal.getSequences())
{
{
return 0;
}
+
+ /**
+ * A sequence/id POST request currently allows up to 50 queries
+ *
+ * @see http://rest.ensembl.org/documentation/info/sequence_id_post
+ */
+ @Override
+ public int getMaximumQueryCount()
+ {
+ return 50;
+ }
+
+ @Override
+ public boolean isDnaCoding()
+ {
+ return true;
+ }
}