JAL-1705 reworked Ensembl clients now fetching and mapping features &
[jalview.git] / src / jalview / ext / ensembl / EnsemblSequenceFetcher.java
diff --git a/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java b/src/jalview/ext/ensembl/EnsemblSequenceFetcher.java
new file mode 100644 (file)
index 0000000..f1b96e2
--- /dev/null
@@ -0,0 +1,80 @@
+package jalview.ext.ensembl;
+
+import jalview.datamodel.DBRefSource;
+import jalview.ws.seqfetcher.DbSourceProxyImpl;
+
+import com.stevesoft.pat.Regex;
+
+/**
+ * A base class for Ensembl sequence fetchers
+ * 
+ * @author gmcarstairs
+ *
+ */
+public abstract class EnsemblSequenceFetcher extends DbSourceProxyImpl
+{
+  /*
+   * possible values for the 'feature' parameter of the REST overlap endpoint
+   * @see 
+   */
+  protected enum EnsemblFeatureType
+  {
+    gene, transcript, cds, exon, repeat, simple, misc, variation,
+    somatic_variation, structural_variation, somatic_structural_variation,
+    constrained, regulatory
+  }
+
+  @Override
+  public String getDbSource()
+  {
+    // NB ensure Uniprot xrefs are canonicalised from "Ensembl" to "ENSEMBL"
+    return DBRefSource.ENSEMBL; // "ENSEMBL"
+  }
+
+  @Override
+  public String getDbVersion()
+  {
+    return "0";
+  }
+
+  @Override
+  public String getAccessionSeparator()
+  {
+    return " ";
+  }
+
+  @Override
+  public Regex getAccessionValidator()
+  {
+    return new Regex("((ENSP|ENST|ENSG|CCDS)[0-9.]{3,})");
+  }
+
+  @Override
+  public boolean isValidReference(String accession)
+  {
+    return getAccessionValidator().search(accession);
+  }
+
+  @Override
+  public int getTier()
+  {
+    return 0;
+  }
+
+  /**
+   * Default test query is a transcript
+   */
+  @Override
+  public String getTestQuery()
+  {
+    // has CDS on reverse strand:
+    return "ENST00000288602";
+    // ENST00000461457 // forward strand
+  }
+
+  @Override
+  public boolean isDnaCoding()
+  {
+    return true;
+  }
+}