annotate hubArchiveCreator.py @ 27:6872b9583e26 draft

planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit e42ecb807fb34a8e4ddcf96944dd74d24c695352-dirty
author yating-l
date Thu, 29 Dec 2016 17:26:29 -0500
parents 3f7c40fb51e8
children 364b8db8de17
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
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
31
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
32 # 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
33
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 def main(argv):
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
36 # Command Line parsing init
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
37 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
38
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
39 # Reference genome mandatory
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
40 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
41
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
42 # GFF3 Management
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
43 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
44
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
45 # GTF 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('--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
47
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
48 # Bed4+12 (TrfBig)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
49 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
50
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
51 # Bed12+1 (regtools)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
52 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
53
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
54 # 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
55 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
56
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
57 # Bed12+12 (tblastn)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
58 parser.add_argument('--bigpsl', action='append', help='bigPsl format')
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
59
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
60 # BigWig Management
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
61 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
62
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
63 # Bam Management
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
64 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
65
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
66 # Psl Management
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
67 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
68
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
69 # 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
70 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
71 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
72 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
73 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
74 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
75 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
76 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
77
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
78 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
79
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
80 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
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('--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
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('--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
85
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
86 # Begin init variables
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 toolDirectory = '.'
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
89 extra_files_path = '.'
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
90
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
91 # 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
92 args = parser.parse_args()
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 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
95 toolDirectory = args.directory
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
96
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
97 #### Logging management ####
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
98 # 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
99
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
100 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
101
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
102 #### END Logging management ####
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 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
105
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
106 # 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
107 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
108 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
109 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
110
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
111 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
112 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
113
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
114 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
115
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
116
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
117 # 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
118 # 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
119 # 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
120 # 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
121 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
122 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
123 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
124 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
125 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
126 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
127 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
128 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
129 array_inputs_bigpsl = args.bigpsl
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
130
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
131 outputFile = args.output
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
132
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
133 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
134
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
135 # 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
136 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
137 # 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
138 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
139
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
140 # 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
141
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
142 # 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
143 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
144
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
145 all_datatype_dictionary = {}
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 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
148 (array_inputs_bam, Bam),
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
149 (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
150 (array_inputs_bigwig, BigWig),
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
151 (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
152 (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
153 (array_inputs_gff3, Gff3),
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
154 (array_inputs_gtf, Gtf),
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
155 (array_inputs_psl, Psl),
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
156 (array_inputs_bigpsl, bigPsl)]:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
157 if inputs:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
158 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
159
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
160 # 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
161 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
162
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
163 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
164 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
165
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
166 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
167 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
168 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
169 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
170
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
171 # 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
172 #trackHub.createZip()
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
173
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
174 # 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
175 trackHub.terminate()
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 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
178
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
179 sys.exit(0)
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
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
182 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
183 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
184 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
185
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
186 :param string_to_sanitize:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
187 :return :
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 :Example:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
190
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
191 >>> 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
192 this_is_an__example
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
193 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
194 return string_to_sanitize \
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
195 .replace("/", "_") \
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
196 .replace(" ", "_")
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
197
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 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
200 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
201 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
202
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
203 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
204 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
205
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
206 :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
207 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
208 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
209 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
210
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 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
213 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
214 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
215 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
216
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
217 :param ExtensionClass:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
218 :param array_inputs:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
219 :param inputs_data:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
220 :type ExtensionClass: Datatype
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
221 :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
222 :type inputs_data: dict
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
223 :rtype: dict
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
224 """
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 datatype_dictionary = {}
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
227
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
228 # 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
229 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
230 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
231 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
232 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
233 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
234 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
235 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
236 return datatype_dictionary
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
237
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
238 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
239 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
240 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
241
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 # 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
244 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
245 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
246
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
247 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
248
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
249 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
250 if not debug:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
251 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
252 else:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
253 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
254
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
255 # stderr configuration
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
256 configure_logger_stderr()
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
257
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
258 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
259
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
260 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
261 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
262 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
263 - 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
264 in STDOUT
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
265 - 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
266 in STDERR
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
267 - 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
268 in .log
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
269
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
270 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
271
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
272 if not log_stdout:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
273 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
274
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
275 # 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
276 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
277
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
278 formatter = TraceBackFormatter('%(message)s')
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 log_stdout.setFormatter(formatter)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
281
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
282 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
283
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
284 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
285 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
286 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
287 - 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
288 - 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
289 - 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
290
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 if not log_stdout:
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
293 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
294 log_format = '%(message)s'
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 # 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
297 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
298
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
299 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
300
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
301 log_stdout.setFormatter(formatter)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
302
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
303 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
304
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
305 def configure_logger_stderr():
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 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
308 """
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
309 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
310 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
311 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
312
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
313 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
314
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
315 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
316
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
317 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
318
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
319 if __name__ == "__main__":
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
320 logging.getLogger(__name__)
3f7c40fb51e8 planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
yating-l
parents:
diff changeset
321 main(sys.argv)