Mercurial > repos > yating-l > hubarchivecreator
annotate util/index/TrixIndex.py @ 85:a65e52152476 draft default tip
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
author | yating-l |
---|---|
date | Mon, 06 Nov 2017 13:13:01 -0500 |
parents | cb62314a6297 |
children |
rev | line source |
---|---|
83
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
1 #!/usr/bin/python |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
2 |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
3 import os |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
4 import collections |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
5 import shutil |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
6 import logging |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
7 from ExternIndex import ExternIndex |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
8 |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
9 class TrixIndex(ExternIndex): |
84
cb62314a6297
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
83
diff
changeset
|
10 def __init__(self, indexIx, indexIxx, trackName, mySpecieFolderPath, trixId, **args): |
83
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
11 self.logger = logging.getLogger(__name__) |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
12 self.indexIx = indexIx |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
13 self.indexIxx = indexIxx |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
14 self.trackName = trackName |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
15 self.mySpecieFolderPath = mySpecieFolderPath |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
16 self.index_settings = collections.OrderedDict() |
85
a65e52152476
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 1a81ebd0ddea950b84af3fc830e9267a4814b29f
yating-l
parents:
84
diff
changeset
|
17 self.trixId = trixId.rstrip() |
84
cb62314a6297
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
83
diff
changeset
|
18 |
83
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
19 |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
20 def setExtLink(self): |
84
cb62314a6297
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
83
diff
changeset
|
21 self.setSearchIndex() |
83
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
22 self.moveIndexFile() |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
23 self.index_settings["searchTrix"] = "trix/%s" % self.indexIxName |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
24 return self.index_settings |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
25 |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
26 def moveIndexFile(self): |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
27 indexFolder = os.path.join(self.mySpecieFolderPath, 'trix') |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
28 self.indexIxName = "".join( ( self.trackName, ".ix") ) |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
29 self.indexIxxName = "".join( ( self.trackName, ".ixx") ) |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
30 if not os.path.exists(indexFolder): |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
31 os.makedirs(indexFolder) |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
32 |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
33 # Move index files to the index folder |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
34 self.indexIxPath = os.path.join(indexFolder, self.indexIxName) |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
35 shutil.copyfile(self.indexIx, self.indexIxPath) |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
36 self.indexIxxPath = os.path.join(indexFolder, self.indexIxxName) |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
37 shutil.copyfile(self.indexIxx, self.indexIxxPath) |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
38 |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
39 def setSearchIndex(self): |
84
cb62314a6297
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
83
diff
changeset
|
40 if not self.trixId: |
cb62314a6297
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
83
diff
changeset
|
41 self.logger.error("Didn't specify Trix Id") |
cb62314a6297
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
83
diff
changeset
|
42 self.logger.debug("trixId= %s, searchIndex= %s", self.trixId, self.trixId) |
cb62314a6297
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
83
diff
changeset
|
43 self.index_settings["searchIndex"] = self.trixId |
83
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
44 |
0bc486356e2a
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit ac73da32d59853ca563e7939d05016a6f3a6899e-dirty
yating-l
parents:
diff
changeset
|
45 |