Mercurial > repos > yating-l > jbrowsearchivecreator
annotate util/Reader.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 | 061da5d3a219 |
children |
rev | line source |
---|---|
39
4a69515eed63
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 91271a6c0d39c923f0d460b2979247baa297286b-dirty
yating-l
parents:
33
diff
changeset
|
1 import os |
25
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
2 import json |
39
4a69515eed63
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 91271a6c0d39c923f0d460b2979247baa297286b-dirty
yating-l
parents:
33
diff
changeset
|
3 import shutil |
25
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
4 import logging |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
5 import codecs |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
6 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
7 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
8 # Internal dependencies |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
9 from datatypes.binary.Bam import Bam |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
10 from datatypes.binary.BigWig import BigWig |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
11 from datatypes.interval.Bed import Bed |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
12 from datatypes.interval.BedSimpleRepeats import BedSimpleRepeats |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
13 from datatypes.interval.BedSpliceJunctions import BedSpliceJunctions |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
14 from datatypes.interval.BlastXml import BlastXml |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
15 from datatypes.interval.Gff3 import Gff3 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
16 from datatypes.interval.Gtf import Gtf |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
17 from datatypes.interval.BigPsl import BigPsl |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
18 from datatypes.interval.BedBlatAlignments import BedBlatAlignments |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
19 from datatypes.interval.BedBlastAlignments import BedBlastAlignments |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
20 from datatypes.interval.Psl import Psl |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
21 from datatypes.sequence.Fasta import Fasta |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
22 from util import santitizer |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
23 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
24 class Reader(object): |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
25 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
26 DATATYPE_CLASS = [Bam, BigWig, Bed, BedSimpleRepeats, |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
27 BedSpliceJunctions, BigPsl, BedBlatAlignments, BedBlastAlignments, |
33
07cc5384dd61
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 74a020b6b0a2fa7ff5670d7f154de838dee51dfd
yating-l
parents:
32
diff
changeset
|
28 BlastXml, Gff3, Gtf, Psl, Fasta] |
25
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
29 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
30 def __init__(self, input_json_file): |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
31 self.inputFile = input_json_file |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
32 self.args = self.loadJson() |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
33 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
34 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
35 def loadJson(self): |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
36 try: |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
37 data_file = codecs.open(self.inputFile, 'r', 'utf-8') |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
38 return json.load(data_file) |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
39 except IOError: |
40
b1553f2a4942
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 12fb52d5b285935b2353d93a5aa291838df7893e
yating-l
parents:
39
diff
changeset
|
40 print ("Cannot find JSON file\n") |
25
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
41 exit(1) |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
42 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
43 def getToolDir(self): |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
44 try: |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
45 return self.args["tool_directory"] |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
46 except KeyError: |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
47 print ("tool_directory is not defined in the input file!") |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
48 exit(1) |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
49 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
50 def getExtFilesPath(self): |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
51 try: |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
52 return self.args["extra_files_path"] |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
53 except KeyError: |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
54 print ("extra_files_path is not defined in the input file!") |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
55 exit(1) |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
56 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
57 def getUserEmail(self): |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
58 try: |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
59 return self.args["user_email"] |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
60 except KeyError: |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
61 print ("user_email is not defined in the input file!") |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
62 exit(1) |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
63 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
64 def getDebugMode(self): |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
65 try: |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
66 return self.args["debug_mode"] |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
67 except KeyError: |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
68 print ("debug_mode is not defined in the input file!") |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
69 exit(1) |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
70 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
71 def getTrackType(self): |
39
4a69515eed63
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 91271a6c0d39c923f0d460b2979247baa297286b-dirty
yating-l
parents:
33
diff
changeset
|
72 try: |
4a69515eed63
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 91271a6c0d39c923f0d460b2979247baa297286b-dirty
yating-l
parents:
33
diff
changeset
|
73 return self.args.get("feature_tracks_type") |
4a69515eed63
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 91271a6c0d39c923f0d460b2979247baa297286b-dirty
yating-l
parents:
33
diff
changeset
|
74 except KeyError: |
4a69515eed63
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 91271a6c0d39c923f0d460b2979247baa297286b-dirty
yating-l
parents:
33
diff
changeset
|
75 print ("feature tracks type is not defined in the input file!") |
4a69515eed63
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 91271a6c0d39c923f0d460b2979247baa297286b-dirty
yating-l
parents:
33
diff
changeset
|
76 exit(1) |
25
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
77 |
32
7b955a58d8f2
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 18da3c5b92673ba5030c24c981c6ca7ebe0bf097-dirty
yating-l
parents:
31
diff
changeset
|
78 def getGenomeName(self): |
7b955a58d8f2
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 18da3c5b92673ba5030c24c981c6ca7ebe0bf097-dirty
yating-l
parents:
31
diff
changeset
|
79 genome_name = santitizer.sanitize_name_input(self.args["genome_name"]) |
7b955a58d8f2
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 18da3c5b92673ba5030c24c981c6ca7ebe0bf097-dirty
yating-l
parents:
31
diff
changeset
|
80 return genome_name |
25
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
81 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
82 def getRefGenome(self): |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
83 array_inputs_reference_genome = self.args["fasta"] |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
84 input_fasta_file = array_inputs_reference_genome["false_path"] |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
85 input_fasta_file_name = santitizer.sanitize_name_input(array_inputs_reference_genome["name"]) |
39
4a69515eed63
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 91271a6c0d39c923f0d460b2979247baa297286b-dirty
yating-l
parents:
33
diff
changeset
|
86 # Add "fasta" extension because Apollo needs it to create annotation |
4a69515eed63
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 91271a6c0d39c923f0d460b2979247baa297286b-dirty
yating-l
parents:
33
diff
changeset
|
87 refseq_file = os.path.join(os.path.dirname(input_fasta_file), input_fasta_file_name + ".fasta") |
4a69515eed63
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 91271a6c0d39c923f0d460b2979247baa297286b-dirty
yating-l
parents:
33
diff
changeset
|
88 shutil.copyfile(input_fasta_file, refseq_file) |
32
7b955a58d8f2
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 18da3c5b92673ba5030c24c981c6ca7ebe0bf097-dirty
yating-l
parents:
31
diff
changeset
|
89 genome_name = self.getGenomeName() |
39
4a69515eed63
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 91271a6c0d39c923f0d460b2979247baa297286b-dirty
yating-l
parents:
33
diff
changeset
|
90 reference_genome = Fasta(refseq_file, |
25
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
91 input_fasta_file_name, genome_name) |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
92 return reference_genome |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
93 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
94 def getTracksData(self): |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
95 self.logger = logging.getLogger(__name__) |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
96 all_datatype_dictionary = dict() |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
97 for datatype in self.DATATYPE_CLASS: |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
98 class_name = datatype.__name__ |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
99 array_inputs = self.args.get(str(class_name)) |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
100 if array_inputs: |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
101 self.logger.debug("Creating %s objects\n", class_name) |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
102 self.logger.debug("array_inputs: %s", array_inputs) |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
103 all_datatype_dictionary.update(self.create_ordered_datatype_objects(datatype, array_inputs)) |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
104 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
105 return all_datatype_dictionary |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
106 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
107 def create_ordered_datatype_objects(self, ExtensionClass, array_inputs): |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
108 """ |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
109 Function which executes the creation all the necessary files / folders for a special Datatype, for TrackHub |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
110 and update the dictionary of datatype |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
111 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
112 :param ExtensionClass: |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
113 :param array_inputs: |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
114 :type ExtensionClass: Datatype |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
115 :type array_inputs: list[string] |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
116 """ |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
117 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
118 datatype_dictionary = {} |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
119 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
120 # TODO: Optimize this double loop |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
121 for input_data in array_inputs: |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
122 input_false_path = input_data["false_path"] |
46
061da5d3a219
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit 3160592f4119e684ab5843dd28a2e6cf11df0121-dirty
yating-l
parents:
40
diff
changeset
|
123 # if the file is empty, skip the rest |
061da5d3a219
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit 3160592f4119e684ab5843dd28a2e6cf11df0121-dirty
yating-l
parents:
40
diff
changeset
|
124 if os.path.isfile(input_false_path) and os.path.getsize(input_false_path) > 0: |
061da5d3a219
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit 3160592f4119e684ab5843dd28a2e6cf11df0121-dirty
yating-l
parents:
40
diff
changeset
|
125 input_data["name"] = santitizer.sanitize_name_input(input_data["name"]) |
061da5d3a219
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit 3160592f4119e684ab5843dd28a2e6cf11df0121-dirty
yating-l
parents:
40
diff
changeset
|
126 extensionObject = ExtensionClass(input_false_path, input_data) |
061da5d3a219
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit 3160592f4119e684ab5843dd28a2e6cf11df0121-dirty
yating-l
parents:
40
diff
changeset
|
127 extensionObject.generateCustomTrack() |
061da5d3a219
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit 3160592f4119e684ab5843dd28a2e6cf11df0121-dirty
yating-l
parents:
40
diff
changeset
|
128 datatype_dictionary.update({input_data["order_index"]: extensionObject}) |
061da5d3a219
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit 3160592f4119e684ab5843dd28a2e6cf11df0121-dirty
yating-l
parents:
40
diff
changeset
|
129 self.logger.debug("%s object: %s has been created", ExtensionClass, input_data["name"]) |
061da5d3a219
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit 3160592f4119e684ab5843dd28a2e6cf11df0121-dirty
yating-l
parents:
40
diff
changeset
|
130 else: |
061da5d3a219
planemo upload for repository https://github.com/goeckslab/jbrowse-archive-creator.git commit 3160592f4119e684ab5843dd28a2e6cf11df0121-dirty
yating-l
parents:
40
diff
changeset
|
131 self.logger.info("The input file: %s is empty, skip creating the track for this data", input_data["name"]) |
25
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
132 return datatype_dictionary |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
133 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
134 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
135 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
136 |
31a41ce128cc
planemo upload for repository https://github.com/Yating-L/jbrowse-archive-creator.git commit 691e5366893905d30943a3cb8cdfb6341f0f5362-dirty
yating-l
parents:
diff
changeset
|
137 |