comparison util/index/TrixIndex.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
comparison
equal deleted inserted replaced
5:e762f4b9e4bd 6:237707a6b74d
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.trixId = trixId.strip()
17 if not self.trixId:
18 self.logger.error("Didn't specify the Trix identifier. To use TRIX index, you need to specify the identifier")
19 exit(1)
20 if "default_index" in args:
21 self.default_index = args["default_index"]
22 else:
23 self.default_index = None
24 self.index_settings = collections.OrderedDict()
25
26 def setExtLink(self):
27 self.setSearchIndex()
28 self.moveIndexFile()
29 self.index_settings["searchTrix"] = "trix/%s" % self.indexIxName
30 return self.index_settings
31
32 def moveIndexFile(self):
33 indexFolder = os.path.join(self.mySpecieFolderPath, 'trix')
34 self.indexIxName = "".join( ( self.trackName, ".ix") )
35 self.indexIxxName = "".join( ( self.trackName, ".ixx") )
36 if not os.path.exists(indexFolder):
37 os.makedirs(indexFolder)
38
39 # Move index files to the index folder
40 self.indexIxPath = os.path.join(indexFolder, self.indexIxName)
41 shutil.copyfile(self.indexIx, self.indexIxPath)
42 self.indexIxxPath = os.path.join(indexFolder, self.indexIxxName)
43 shutil.copyfile(self.indexIxx, self.indexIxxPath)
44
45 def setSearchIndex(self):
46 if self.default_index:
47 set_index = set()
48 set_index.add(self.trixId)
49 set_index.add(self.default_index)
50 search_index = ",".join(set_index)
51 else:
52 search_index = self.trixId
53 logging.debug("trixId= %s, searchIndex= %s", self.trixId, search_index)
54 self.index_settings["searchIndex"] = search_index
55