Mercurial > repos > yating-l > jbrowsearchivecreator
annotate util/index/DatabaseIndex.py @ 50:804e7217f27c draft default tip
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit 3afab1eb0da4823419945c523a1d37cd5973e7f6-dirty
| author | yating-l | 
|---|---|
| date | Fri, 20 Jul 2018 11:38:01 -0400 | 
| parents | be34d213ec6a | 
| children | 
| 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") | 
| 49 
be34d213ec6a
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit e526b4e8bef4677b832e940bacb8969a18efc3e3
 yating-l parents: 
25diff
changeset | 10 | 
| 25 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 11 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 12 def setExtLink(self): | 
| 49 
be34d213ec6a
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit e526b4e8bef4677b832e940bacb8969a18efc3e3
 yating-l parents: 
25diff
changeset | 13 return self.setDatabaseLink(self.database, self.seqType) | 
| 25 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 14 | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 15 | 
| 49 
be34d213ec6a
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit e526b4e8bef4677b832e940bacb8969a18efc3e3
 yating-l parents: 
25diff
changeset | 16 def setDatabaseLink(self, database, seqType=None): | 
| 25 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 17 database_settings = collections.OrderedDict() | 
| 49 
be34d213ec6a
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit e526b4e8bef4677b832e940bacb8969a18efc3e3
 yating-l parents: 
25diff
changeset | 18 database_settings.update({"label": "View feature details in the database", | 
| 
be34d213ec6a
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit e526b4e8bef4677b832e940bacb8969a18efc3e3
 yating-l parents: 
25diff
changeset | 19 "action": "iframeDialog", | 
| 
be34d213ec6a
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit e526b4e8bef4677b832e940bacb8969a18efc3e3
 yating-l parents: 
25diff
changeset | 20 "iconClass": "dijitIconDatabase", | 
| 
be34d213ec6a
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit e526b4e8bef4677b832e940bacb8969a18efc3e3
 yating-l parents: 
25diff
changeset | 21 "title": "feature {name}"}) | 
| 
be34d213ec6a
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit e526b4e8bef4677b832e940bacb8969a18efc3e3
 yating-l parents: 
25diff
changeset | 22 | 
| 25 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 23 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 | 24 if not seqType: | 
| 49 
be34d213ec6a
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit e526b4e8bef4677b832e940bacb8969a18efc3e3
 yating-l parents: 
25diff
changeset | 25 database_settings["url"] = "https://www.ncbi.nlm.nih.gov/gquery/?term={name}" | 
| 25 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 26 elif seqType == 2: | 
| 49 
be34d213ec6a
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit e526b4e8bef4677b832e940bacb8969a18efc3e3
 yating-l parents: 
25diff
changeset | 27 database_settings["url"] = "https://www.ncbi.nlm.nih.gov/protein/{name}" | 
| 25 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 28 elif seqType == 1: | 
| 49 
be34d213ec6a
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit e526b4e8bef4677b832e940bacb8969a18efc3e3
 yating-l parents: 
25diff
changeset | 29 database_settings["url"] = "https://www.ncbi.nlm.nih.gov/nuccore/{name}" | 
| 25 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 30 else: | 
| 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 31 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 | 32 elif "UniProt" in database: | 
| 49 
be34d213ec6a
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit e526b4e8bef4677b832e940bacb8969a18efc3e3
 yating-l parents: 
25diff
changeset | 33 database_settings["url"] = "http://www.uniprot.org/uniprot/{name}" | 
| 25 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 34 elif "FlyBase" in database: | 
| 49 
be34d213ec6a
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit e526b4e8bef4677b832e940bacb8969a18efc3e3
 yating-l parents: 
25diff
changeset | 35 database_settings["url"] = "http://flybase.org/reports/{name}" | 
| 25 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 36 else: | 
| 49 
be34d213ec6a
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit e526b4e8bef4677b832e940bacb8969a18efc3e3
 yating-l parents: 
25diff
changeset | 37 database_settings["url"] = "https://www.ncbi.nlm.nih.gov/gquery/?term={name}" | 
| 25 
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
 yating-l parents: diff
changeset | 38 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 | 39 | 
