annotate hubArchiveCreator.py @ 55:ba9997c847dc draft

planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b2894a39921adaa6a93b12523820b61a78e11f20-dirty
author yating-l
date Wed, 17 May 2017 13:16:57 -0400
parents 4a58094b051e
children 4ca7cbf2d9b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
1 #!/usr/bin/python
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
2 # -*- coding: utf8 -*-
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
3
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
4 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
5 This Galaxy tool permits to prepare your files to be ready for
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
6 Assembly Hub visualization.
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
7 Program test arguments:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
8 hubArchiveCreator.py -g test-data/augustusDbia3.gff3 -f test-data/dbia3.fa -d . -u ./tools -o output.html
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
9 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
10
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
11 import argparse
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
12 import collections
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
13 import json
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
14 import logging
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
15 import os
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
16 import sys
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
17
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
18 # Internal dependencies
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
19 from Bam import Bam
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
20 from BedSimpleRepeats import BedSimpleRepeats
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
21 from BedSpliceJunctions import BedSpliceJunctions
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
22 from Bed import Bed
54
4a58094b051e planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 754b3f960221a68b90f9cddd98a1c3dd324d4d4e-dirty
yating-l
parents: 51
diff changeset
23 from cytoBand import cytoBand
11
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
24 from BigWig import BigWig
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
25 from util.Fasta import Fasta
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
26 from util.Filters import TraceBackFormatter
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
27 from Gff3 import Gff3
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
28 from Gtf import Gtf
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
29 from Psl import Psl
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
30 from TrackHub import TrackHub
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
31 from bigPsl import bigPsl
51
364b8db8de17 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
yating-l
parents: 11
diff changeset
32 from BedBlastAlignments import BedBlastAlignments
55
ba9997c847dc planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b2894a39921adaa6a93b12523820b61a78e11f20-dirty
yating-l
parents: 54
diff changeset
33 from BigBed import BigBed
11
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
34
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
35 # TODO: Verify each subprocessed dependency is accessible [gff3ToGenePred, genePredToBed, twoBitInfo, faToTwoBit, bedToBigBed, sort
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
36
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
37
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
38 def main(argv):
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
39 # Command Line parsing init
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
40 parser = argparse.ArgumentParser(description='Create a foo.txt inside the given folder.')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
41
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
42 # Reference genome mandatory
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
43 parser.add_argument('-f', '--fasta', help='Fasta file of the reference genome')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
44
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
45 # GFF3 Management
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
46 parser.add_argument('--gff3', action='append', help='GFF3 format')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
47
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
48 # GTF Management
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
49 parser.add_argument('--gtf', action='append', help='GTF format')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
50
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
51 # Bed4+12 (TrfBig)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
52 parser.add_argument('--bedSimpleRepeats', action='append', help='Bed4+12 format, using simpleRepeats.as')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
53
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
54 # Bed12+1 (regtools)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
55 parser.add_argument('--bedSpliceJunctions', action='append', help='Bed12+1 format, using spliceJunctions.as')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
56
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
57 # Generic Bed (Blastx transformed to bed)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
58 parser.add_argument('--bed', action='append', help='Bed generic format')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
59
54
4a58094b051e planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 754b3f960221a68b90f9cddd98a1c3dd324d4d4e-dirty
yating-l
parents: 51
diff changeset
60 #cytoBandIdeo
4a58094b051e planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 754b3f960221a68b90f9cddd98a1c3dd324d4d4e-dirty
yating-l
parents: 51
diff changeset
61 parser.add_argument('--cytoBand', action='append', help='Cytoband Track, using cytoBandIdeo.as')
4a58094b051e planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 754b3f960221a68b90f9cddd98a1c3dd324d4d4e-dirty
yating-l
parents: 51
diff changeset
62
51
364b8db8de17 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
yating-l
parents: 11
diff changeset
63 # BigPsl (blat alignment)
364b8db8de17 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
yating-l
parents: 11
diff changeset
64 parser.add_argument('--bigpsl', action='append', help='bigPsl format, using bigPsl.as')
364b8db8de17 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
yating-l
parents: 11
diff changeset
65
364b8db8de17 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
yating-l
parents: 11
diff changeset
66 # Bed12+12 (tblastn alignment)
364b8db8de17 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
yating-l
parents: 11
diff changeset
67 parser.add_argument('--bedBlastAlignments', action='append', help='Bed12+12 format, using bigPsl.as')
11
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
68
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
69 # BigWig Management
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
70 parser.add_argument('--bigwig', action='append', help='BigWig format')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
71
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
72 # Bam Management
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
73 parser.add_argument('--bam', action='append', help='Bam format')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
74
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
75 # Psl Management
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
76 parser.add_argument('--psl', action='append', help='Psl format')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
77
55
ba9997c847dc planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b2894a39921adaa6a93b12523820b61a78e11f20-dirty
yating-l
parents: 54
diff changeset
78 # BigBed Management
ba9997c847dc planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b2894a39921adaa6a93b12523820b61a78e11f20-dirty
yating-l
parents: 54
diff changeset
79 parser.add_argument('--bigbed', action='append', help='BigBed format')
ba9997c847dc planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b2894a39921adaa6a93b12523820b61a78e11f20-dirty
yating-l
parents: 54
diff changeset
80
11
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
81 # TODO: Check if the running directory can have issues if we run the tool outside
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
82 parser.add_argument('-d', '--directory',
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
83 help='Running tool directory, where to find the templates. Default is running directory')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
84 parser.add_argument('-u', '--ucsc_tools_path',
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
85 help='Directory where to find the executables needed to run this tool')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
86 parser.add_argument('-e', '--extra_files_path',
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
87 help='Name, in galaxy, of the output folder. Where you would want to build the Track Hub Archive')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
88 parser.add_argument('-o', '--output', help='Name of the HTML summarizing the content of the Track Hub Archive')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
89
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
90 parser.add_argument('-j', '--data_json', help='Json containing the metadata of the inputs')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
91
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
92 parser.add_argument('--user_email', help='Email of the user who launched the Hub Archive Creation')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
93
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
94 parser.add_argument('--genome_name', help='UCSC Genome Browser assembly ID')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
95
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
96 parser.add_argument('--debug_mode', action='store_true', help='Allow more details about the errors')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
97
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
98 # Begin init variables
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
99
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
100 toolDirectory = '.'
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
101 extra_files_path = '.'
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
102
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
103 # Get the args passed in parameter
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
104 args = parser.parse_args()
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
105
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
106 extra_files_path = args.extra_files_path
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
107 toolDirectory = args.directory
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
108
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
109 #### Logging management ####
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
110 # If we are in Debug mode, also print in stdout the debug dump
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
111
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
112 configure_logger(extra_files_path=extra_files_path, debug=args.debug_mode)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
113
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
114 #### END Logging management ####
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
115
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
116 array_inputs_reference_genome = json.loads(args.fasta)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
117
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
118 # TODO: Replace these with the object Fasta
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
119 input_fasta_file = array_inputs_reference_genome["false_path"]
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
120 input_fasta_file_name = sanitize_name_input(array_inputs_reference_genome["name"])
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
121 genome_name = sanitize_name_input(args.genome_name)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
122
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
123 reference_genome = Fasta(input_fasta_file,
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
124 input_fasta_file_name, genome_name)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
125
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
126 user_email = args.user_email
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
127
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
128
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
129 # TODO: Use a class to have a better management of the structure of these inputs
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
130 # These inputs are populated in the Galaxy Wrapper xml and are in this format:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
131 # ARRAY[DICT{FILE_PATH: DICT{NAME: NAME_VALUE, EXTRA_DATA: EXTRA_DATA_VALUE}}]
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
132 # EXTRA_DATA could be anything, for example the index of a BAM => {"index", FILE_PATH}
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
133 array_inputs_bam = args.bam
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
134 array_inputs_bed_generic = args.bed
54
4a58094b051e planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 754b3f960221a68b90f9cddd98a1c3dd324d4d4e-dirty
yating-l
parents: 51
diff changeset
135 array_inputs_bed_cytoBand = args.cytoBand
11
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
136 array_inputs_bed_simple_repeats = args.bedSimpleRepeats
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
137 array_inputs_bed_splice_junctions = args.bedSpliceJunctions
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
138 array_inputs_bigwig = args.bigwig
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
139 array_inputs_gff3 = args.gff3
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
140 array_inputs_gtf = args.gtf
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
141 array_inputs_psl = args.psl
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
142 array_inputs_bigpsl = args.bigpsl
51
364b8db8de17 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
yating-l
parents: 11
diff changeset
143 array_inputs_bed_blast_alignments = args.bedBlastAlignments
55
ba9997c847dc planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b2894a39921adaa6a93b12523820b61a78e11f20-dirty
yating-l
parents: 54
diff changeset
144 array_inputs_bigbed = args.bigbed
11
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
145
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
146 outputFile = args.output
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
147
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
148 json_inputs_data = args.data_json
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
149
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
150 # TODO: Instead use a class to properly store the objects, with object_hook
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
151 inputs_data = json.loads(json_inputs_data)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
152 # We remove the spaces in ["name"] of inputs_data
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
153 sanitize_name_inputs(inputs_data)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
154
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
155 # TODO: Check here all the binaries / tools we need. Exception if missing
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
156
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
157 # Create the Track Hub folder
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
158 trackHub = TrackHub(reference_genome, user_email, outputFile, extra_files_path, toolDirectory)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
159
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
160 all_datatype_dictionary = {}
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
161
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
162 for (inputs, datatype_class) in [
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
163 (array_inputs_bam, Bam),
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
164 (array_inputs_bed_generic, Bed),
54
4a58094b051e planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 754b3f960221a68b90f9cddd98a1c3dd324d4d4e-dirty
yating-l
parents: 51
diff changeset
165 (array_inputs_bed_cytoBand, cytoBand),
11
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
166 (array_inputs_bigwig, BigWig),
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
167 (array_inputs_bed_simple_repeats, BedSimpleRepeats),
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
168 (array_inputs_bed_splice_junctions, BedSpliceJunctions),
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
169 (array_inputs_gff3, Gff3),
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
170 (array_inputs_gtf, Gtf),
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
171 (array_inputs_psl, Psl),
51
364b8db8de17 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
yating-l
parents: 11
diff changeset
172 (array_inputs_bigpsl, bigPsl),
55
ba9997c847dc planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b2894a39921adaa6a93b12523820b61a78e11f20-dirty
yating-l
parents: 54
diff changeset
173 (array_inputs_bed_blast_alignments, BedBlastAlignments),
ba9997c847dc planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit b2894a39921adaa6a93b12523820b61a78e11f20-dirty
yating-l
parents: 54
diff changeset
174 (array_inputs_bigbed, BigBed)]:
11
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
175 if inputs:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
176 all_datatype_dictionary.update(create_ordered_datatype_objects(datatype_class, inputs, inputs_data))
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
177
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
178 # Create Ordered Dictionary to add the tracks in the tool form order
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
179 all_datatype_ordered_dictionary = collections.OrderedDict(all_datatype_dictionary)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
180
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
181 logging.debug("----- End of all_datatype_dictionary processing -----")
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
182 logging.debug("all_datatype_ordered_dictionary keys are: {0}".format(all_datatype_ordered_dictionary.values()))
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
183
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
184 logging.debug("----- Beginning of Track adding processing -----")
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
185 for index, datatypeObject in all_datatype_ordered_dictionary.iteritems():
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
186 trackHub.addTrack(datatypeObject.track.trackDb)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
187 logging.debug("----- End of Track adding processing -----")
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
188
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
189 # We process all the modifications to create the zip file
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
190 #trackHub.createZip()
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
191
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
192 # We terminate le process and so create a HTML file summarizing all the files
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
193 trackHub.terminate()
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
194
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
195 logging.debug('#### End of HubArchiveCreator Debug Mode: Bye! ####')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
196
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
197 sys.exit(0)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
198
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
199
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
200 def sanitize_name_input(string_to_sanitize):
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
201 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
202 Sanitize the string passed in parameter by replacing '/' and ' ' by '_'
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
203
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
204 :param string_to_sanitize:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
205 :return :
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
206
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
207 :Example:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
208
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
209 >>> sanitize_name_input('this/is an//example')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
210 this_is_an__example
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
211 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
212 return string_to_sanitize \
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
213 .replace("/", "_") \
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
214 .replace(" ", "_")
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
215
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
216
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
217 def sanitize_name_inputs(inputs_data):
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
218 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
219 Sanitize value of the keys "name" of the dictionary passed in parameter.
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
220
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
221 Because sometimes output from Galaxy, or even just file name, from user inputs, have spaces.
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
222 Also, it can contain '/' character and could break the use of os.path function.
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
223
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
224 :param inputs_data: dict[string, dict[string, string]]
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
225 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
226 for key in inputs_data:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
227 inputs_data[key]["name"] = sanitize_name_input(inputs_data[key]["name"])
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
228
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
229
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
230 def create_ordered_datatype_objects(ExtensionClass, array_inputs, inputs_data):
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
231 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
232 Function which executes the creation all the necessary files / folders for a special Datatype, for TrackHub
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
233 and update the dictionary of datatype
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
234
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
235 :param ExtensionClass:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
236 :param array_inputs:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
237 :param inputs_data:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
238 :type ExtensionClass: Datatype
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
239 :type array_inputs: list[string]
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
240 :type inputs_data: dict
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
241 :rtype: dict
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
242 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
243
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
244 datatype_dictionary = {}
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
245
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
246 # TODO: Optimize this double loop
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
247 for input_false_path in array_inputs:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
248 for key, data_value in inputs_data.items():
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
249 if key == input_false_path:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
250 logging.debug("input_false_path: " + input_false_path)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
251 logging.debug("data_value: " + str(data_value))
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
252 extensionObject = ExtensionClass(input_false_path, data_value)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
253 datatype_dictionary.update({data_value["order_index"]: extensionObject})
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
254 return datatype_dictionary
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
255
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
256 def configure_logger(extra_files_path=None, debug=False):
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
257 if not extra_files_path:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
258 raise Exception("Extra files path is not set. Stopping the application")
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
259
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
260
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
261 # All case log: log everything in a .log file
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
262 logger_file_name = ''.join([__name__, '.log'])
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
263 logging_file_path = os.path.join(extra_files_path, logger_file_name)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
264
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
265 logging.basicConfig(filename=logging_file_path, level=logging.DEBUG)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
266
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
267 log_stdout = logging.StreamHandler(sys.stdout)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
268 if not debug:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
269 configure_logger_user(log_stdout)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
270 else:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
271 configure_logger_dev(log_stdout)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
272
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
273 # stderr configuration
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
274 configure_logger_stderr()
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
275
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
276 logging.debug('#### Welcome in HubArchiveCreator Debug Mode ####\n')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
277
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
278 def configure_logger_user(log_stdout=None):
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
279 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
280 User Logger is defined as following:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
281 - User needs to have WARN, ERROR and CRITICAL but well formatted / without traceback
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
282 in STDOUT
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
283 - Still access to full, brute and traceback for errors
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
284 in STDERR
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
285 - And further access to debug if needed
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
286 in .log
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
287
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
288 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
289
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
290 if not log_stdout:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
291 raise Exception("No log_stdout given. Stopping the application")
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
292
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
293 # stdout for INFO / WARN / ERROR / CRITICAL
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
294 log_stdout.setLevel(logging.INFO)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
295
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
296 formatter = TraceBackFormatter('%(message)s')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
297
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
298 log_stdout.setFormatter(formatter)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
299
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
300 logging.getLogger().addHandler(log_stdout)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
301
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
302 def configure_logger_dev(log_stdout=None):
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
303 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
304 Dev Logger is defined as following:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
305 - Dev needs to have WARN, ERROR and CRITICAL but well formatted / without traceback, in stdout
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
306 - Still access to full, brute and traceback in stderr for errors
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
307 - And further access to debug if needed
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
308
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
309 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
310 if not log_stdout:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
311 raise Exception("No log_stdout given. Stopping the application")
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
312 log_format = '%(message)s'
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
313
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
314 # stdout and stderr and both identical for INFO / WARN / ERROR / CRITICAL
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
315 log_stdout.setLevel(logging.DEBUG)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
316
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
317 formatter = logging.Formatter(log_format)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
318
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
319 log_stdout.setFormatter(formatter)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
320
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
321 logging.getLogger().addHandler(log_stdout)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
322
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
323 def configure_logger_stderr():
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
324 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
325 Configure what should be logged in stderr
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
326 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
327 log_error = logging.StreamHandler(sys.stderr)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
328 log_error.setLevel(logging.ERROR)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
329 log_error_format = '%(message)s'
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
330
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
331 formatter_error = logging.Formatter(log_error_format)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
332
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
333 log_error.setFormatter(formatter_error)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
334
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
335 logging.getLogger().addHandler(log_error)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
336
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
337 if __name__ == "__main__":
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
338 logging.getLogger(__name__)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
339 main(sys.argv)