comparison util/Reader.py @ 7:5d5fdcb798da draft

planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 12fb52d5b285935b2353d93a5aa291838df7893e
author yating-l
date Fri, 20 Apr 2018 13:51:23 -0400
parents 237707a6b74d
children 43a700afd457
comparison
equal deleted inserted replaced
6:237707a6b74d 7:5d5fdcb798da
1 import os
1 import json 2 import json
3 import shutil
2 import logging 4 import logging
3 import codecs 5 import codecs
4 6
5 7
6 # Internal dependencies 8 # Internal dependencies
33 def loadJson(self): 35 def loadJson(self):
34 try: 36 try:
35 data_file = codecs.open(self.inputFile, 'r', 'utf-8') 37 data_file = codecs.open(self.inputFile, 'r', 'utf-8')
36 return json.load(data_file) 38 return json.load(data_file)
37 except IOError: 39 except IOError:
38 print "Cannot find JSON file\n" 40 print ("Cannot find JSON file\n")
39 exit(1) 41 exit(1)
40 42
41 def getToolDir(self): 43 def getToolDir(self):
42 try: 44 try:
43 return self.args["tool_directory"] 45 return self.args["tool_directory"]
65 except KeyError: 67 except KeyError:
66 print ("debug_mode is not defined in the input file!") 68 print ("debug_mode is not defined in the input file!")
67 exit(1) 69 exit(1)
68 70
69 def getTrackType(self): 71 def getTrackType(self):
70 track_type = self.args.get("track_type") 72 try:
71 return track_type 73 return self.args.get("feature_tracks_type")
74 except KeyError:
75 print ("feature tracks type is not defined in the input file!")
76 exit(1)
72 77
73 def getGenomeName(self): 78 def getGenomeName(self):
74 genome_name = santitizer.sanitize_name_input(self.args["genome_name"]) 79 genome_name = santitizer.sanitize_name_input(self.args["genome_name"])
75 return genome_name 80 return genome_name
76 81
77 def getRefGenome(self): 82 def getRefGenome(self):
78 array_inputs_reference_genome = self.args["fasta"] 83 array_inputs_reference_genome = self.args["fasta"]
79 # TODO: Replace these with the object Fasta
80 input_fasta_file = array_inputs_reference_genome["false_path"] 84 input_fasta_file = array_inputs_reference_genome["false_path"]
81 input_fasta_file_name = santitizer.sanitize_name_input(array_inputs_reference_genome["name"]) 85 input_fasta_file_name = santitizer.sanitize_name_input(array_inputs_reference_genome["name"])
82 #genome_name = santitizer.sanitize_name_input(self.args["genome_name"]) 86 # Add "fasta" extension because Apollo needs it to create annotation
87 refseq_file = os.path.join(os.path.dirname(input_fasta_file), input_fasta_file_name + ".fasta")
88 shutil.copyfile(input_fasta_file, refseq_file)
83 genome_name = self.getGenomeName() 89 genome_name = self.getGenomeName()
84 reference_genome = Fasta(input_fasta_file, 90 reference_genome = Fasta(refseq_file,
85 input_fasta_file_name, genome_name) 91 input_fasta_file_name, genome_name)
86 return reference_genome 92 return reference_genome
87 93
88 def getTracksData(self): 94 def getTracksData(self):
89 self.logger = logging.getLogger(__name__) 95 self.logger = logging.getLogger(__name__)