annotate hubArchiveCreator.py @ 52:c66803bff0cc draft

planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit adc1ac50269e02570e7ce12c732637bdd3f9a547-dirty
author yating-l
date Thu, 11 May 2017 17:21:15 -0400
parents 364b8db8de17
children 4a58094b051e
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
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
23 from BigWig import BigWig
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
24 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
25 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
26 from Gff3 import Gff3
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
27 from Gtf import Gtf
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
28 from Psl import Psl
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
29 from TrackHub import TrackHub
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
30 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
31 from BedBlastAlignments import BedBlastAlignments
11
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
32
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
33 # 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
34
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
35
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
36 def main(argv):
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
37 # Command Line parsing init
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
38 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
39
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
40 # Reference genome mandatory
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
41 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
42
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
43 # GFF3 Management
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
44 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
45
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
46 # GTF Management
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
47 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
48
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
49 # Bed4+12 (TrfBig)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
50 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
51
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
52 # Bed12+1 (regtools)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
53 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
54
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
55 # 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
56 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
57
51
364b8db8de17 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
yating-l
parents: 11
diff changeset
58 # BigPsl (blat alignment)
364b8db8de17 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
yating-l
parents: 11
diff changeset
59 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
60
364b8db8de17 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
yating-l
parents: 11
diff changeset
61 # 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
62 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
63
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
64 # BigWig Management
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
65 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
66
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
67 # Bam Management
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
68 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
69
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
70 # Psl Management
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
71 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
72
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
73 # 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
74 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
75 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
76 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
77 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
78 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
79 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
80 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
81
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
82 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
83
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
84 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
85
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
86 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
87
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
88 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
89
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
90 # Begin init variables
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 toolDirectory = '.'
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
93 extra_files_path = '.'
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
94
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
95 # 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
96 args = parser.parse_args()
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 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
99 toolDirectory = args.directory
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
100
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
101 #### Logging management ####
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
102 # 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
103
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
104 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
105
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
106 #### END Logging management ####
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
107
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
108 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
109
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
110 # 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
111 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
112 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
113 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
114
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
115 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
116 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
117
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
118 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
119
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
120
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
121 # 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
122 # 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
123 # 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
124 # 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
125 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
126 array_inputs_bed_generic = args.bed
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
127 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
128 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
129 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
130 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
131 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
132 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
133 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
134 array_inputs_bed_blast_alignments = args.bedBlastAlignments
11
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
135
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
136 outputFile = args.output
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
137
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
138 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
139
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
140 # 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
141 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
142 # 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
143 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
144
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
145 # 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
146
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
147 # 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
148 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
149
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
150 all_datatype_dictionary = {}
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
151
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
152 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
153 (array_inputs_bam, Bam),
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
154 (array_inputs_bed_generic, Bed),
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
155 (array_inputs_bigwig, BigWig),
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
156 (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
157 (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
158 (array_inputs_gff3, Gff3),
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
159 (array_inputs_gtf, Gtf),
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
160 (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
161 (array_inputs_bigpsl, bigPsl),
364b8db8de17 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 6ac76e7da539ca1773fb809054679f0bf8a06972-dirty
yating-l
parents: 11
diff changeset
162 (array_inputs_bed_blast_alignments, BedBlastAlignments)]:
11
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
163 if inputs:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
164 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
165
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
166 # 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
167 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
168
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
169 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
170 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
171
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
172 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
173 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
174 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
175 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
176
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
177 # 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
178 #trackHub.createZip()
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
179
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
180 # 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
181 trackHub.terminate()
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
182
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
183 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
184
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
185 sys.exit(0)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
186
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
187
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
188 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
189 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
190 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
191
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
192 :param string_to_sanitize:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
193 :return :
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 :Example:
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 >>> 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
198 this_is_an__example
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 return string_to_sanitize \
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
201 .replace("/", "_") \
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
202 .replace(" ", "_")
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
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
205 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
206 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
207 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
208
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
209 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
210 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
211
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
212 :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
213 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
214 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
215 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
216
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
217
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
218 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
219 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
220 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
221 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
222
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
223 :param ExtensionClass:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
224 :param array_inputs:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
225 :param inputs_data:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
226 :type ExtensionClass: Datatype
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
227 :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
228 :type inputs_data: dict
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
229 :rtype: dict
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
230 """
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 datatype_dictionary = {}
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
233
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
234 # 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
235 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
236 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
237 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
238 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
239 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
240 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
241 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
242 return datatype_dictionary
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 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
245 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
246 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
247
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
248
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
249 # 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
250 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
251 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
252
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
253 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
254
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
255 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
256 if not debug:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
257 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
258 else:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
259 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
260
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
261 # stderr configuration
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
262 configure_logger_stderr()
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
263
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
264 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
265
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
266 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
267 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
268 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
269 - 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
270 in STDOUT
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
271 - 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
272 in STDERR
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
273 - 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
274 in .log
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 """
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 if not log_stdout:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
279 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
280
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
281 # 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
282 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
283
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
284 formatter = TraceBackFormatter('%(message)s')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
285
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
286 log_stdout.setFormatter(formatter)
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 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
289
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
290 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
291 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
292 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
293 - 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
294 - 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
295 - 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
296
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 if not log_stdout:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
299 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
300 log_format = '%(message)s'
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 # 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
303 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
304
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
305 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
306
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
307 log_stdout.setFormatter(formatter)
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 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
310
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
311 def configure_logger_stderr():
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
312 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
313 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
314 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
315 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
316 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
317 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
318
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
319 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
320
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
321 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
322
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
323 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
324
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
325 if __name__ == "__main__":
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
326 logging.getLogger(__name__)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
327 main(sys.argv)