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