diff util/index/DatabaseIndex.py @ 6:237707a6b74d draft

planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit a500f7ab2119cc5faaf80393bd87428389d06880-dirty
author yating-l
date Thu, 15 Feb 2018 17:05:05 -0500
parents
children 3f9971a91096
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/util/index/DatabaseIndex.py	Thu Feb 15 17:05:05 2018 -0500
@@ -0,0 +1,44 @@
+#!/usr/bin/python
+
+import collections
+from ExternIndex import ExternIndex
+
+class DatabaseIndex(ExternIndex):
+    def __init__(self, database, **args):
+        self.database = database
+        self.seqType=args.get("seqType")
+        self.useIframe=args.get("useIframe")
+        self.iframeHeight=args.get("iframeHeight")
+        self.iframeWidth=args.get("iframeWidth")
+
+    def setExtLink(self):
+        return self.setDatabaseLink(self.database, self.seqType, self.useIframe, self.iframeHeight, self.iframeWidth)
+
+    
+    def setDatabaseLink(self, database, seqType=None, useIframe=None, iframeHeight=None, iframeWidth=None):
+        database_settings = collections.OrderedDict()
+        if "NCBI" in database:
+            if not seqType:
+                database_settings["url"] = "https://www.ncbi.nlm.nih.gov/gquery/?term=$$"
+            elif seqType == 2:
+                database_settings["url"] = "https://www.ncbi.nlm.nih.gov/protein/$$"
+            elif seqType == 1:
+                database_settings["url"] = "https://www.ncbi.nlm.nih.gov/nuccore/$$"
+            else:
+                raise Exception("Sequence Type {0} is not valid, should be either protein (seqType==2) or nucleotide (seqType==1). Stopping the application".format(seqType))
+        elif "UniProt" in database:
+            database_settings["url"] = "http://www.uniprot.org/uniprot/$$"
+        elif "FlyBase" in database:
+            database_settings["url"] = "http://flybase.org/reports/$$"
+        else:
+            database_settings["url"] = "https://www.ncbi.nlm.nih.gov/gquery/?term=$$"
+        database_settings["urlLabel"] = database + " Details:"
+        if useIframe or useIframe is None:
+            database_settings["iframeUrl"] = database_settings["url"]
+            if not iframeHeight:
+                iframeHeight = "600"
+            if not iframeWidth:
+                iframeWidth = "800"
+            database_settings["iframeOptions"] = "height= %s width= %s" % (iframeHeight, iframeWidth)
+        return database_settings
+