Mercurial > repos > yating-l > jbrowsearchivecreator
annotate util/index/DatabaseIndex.py @ 48:284c573f36a3 draft
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit 97a743ee6d228c8a0a5778ec3cb6f68a2e22c8e3-dirty
| author | yating-l | 
|---|---|
| date | Tue, 19 Jun 2018 17:53:58 -0400 | 
| parents | 31a41ce128cc | 
| children | be34d213ec6a | 
| rev | line source | 
|---|---|
| 25 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 1 #!/usr/bin/python | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 2 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 3 import collections | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 4 from ExternIndex import ExternIndex | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 5 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 6 class DatabaseIndex(ExternIndex): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 7 def __init__(self, database, **args): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 8 self.database = database | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 9 self.seqType=args.get("seqType") | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 10 self.useIframe=args.get("useIframe") | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 11 self.iframeHeight=args.get("iframeHeight") | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 12 self.iframeWidth=args.get("iframeWidth") | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 13 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 14 def setExtLink(self): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 15 return self.setDatabaseLink(self.database, self.seqType, self.useIframe, self.iframeHeight, self.iframeWidth) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 16 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 17 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 18 def setDatabaseLink(self, database, seqType=None, useIframe=None, iframeHeight=None, iframeWidth=None): | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 19 database_settings = collections.OrderedDict() | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 20 if "NCBI" in database: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 21 if not seqType: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 22 database_settings["url"] = "https://www.ncbi.nlm.nih.gov/gquery/?term=$$" | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 23 elif seqType == 2: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 24 database_settings["url"] = "https://www.ncbi.nlm.nih.gov/protein/$$" | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 25 elif seqType == 1: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 26 database_settings["url"] = "https://www.ncbi.nlm.nih.gov/nuccore/$$" | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 27 else: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 28 raise Exception("Sequence Type {0} is not valid, should be either protein (seqType==2) or nucleotide (seqType==1). Stopping the application".format(seqType)) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 29 elif "UniProt" in database: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 30 database_settings["url"] = "http://www.uniprot.org/uniprot/$$" | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 31 elif "FlyBase" in database: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 32 database_settings["url"] = "http://flybase.org/reports/$$" | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 33 else: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 34 database_settings["url"] = "https://www.ncbi.nlm.nih.gov/gquery/?term=$$" | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 35 database_settings["urlLabel"] = database + " Details:" | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 36 if useIframe or useIframe is None: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 37 database_settings["iframeUrl"] = database_settings["url"] | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 38 if not iframeHeight: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 39 iframeHeight = "600" | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 40 if not iframeWidth: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 41 iframeWidth = "800" | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 42 database_settings["iframeOptions"] = "height= %s width= %s" % (iframeHeight, iframeWidth) | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 43 return database_settings | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 44 | 
