Mercurial > repos > yating-l > jbrowse_hub
diff jbrowse_hub.py @ 5:e7c80e9b70ae draft
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
author | yating-l |
---|---|
date | Tue, 14 Mar 2017 12:24:37 -0400 |
parents | e4f3f2ed4fa5 |
children | e1f188b43750 |
line wrap: on
line diff
--- a/jbrowse_hub.py Fri Mar 10 14:57:36 2017 -0500 +++ b/jbrowse_hub.py Tue Mar 14 12:24:37 2017 -0400 @@ -10,6 +10,7 @@ import tempfile import trackObject import TrackHub +import shutil def main(argv): parser = argparse.ArgumentParser(description='Create a hub to display in jbrowse.') @@ -17,8 +18,14 @@ # Reference genome mandatory parser.add_argument('-f', '--fasta', help='Fasta file of the reference genome') + # Genome name + parser.add_argument('-g', '--genome_name', help='Name of reference genome') + # Output folder - parser.add_argument('-o', '--out', help='Name of the HTML summarizing the content of the JBrowse Hub') + parser.add_argument('-o', '--out', help='output html') + + # Output folder + parser.add_argument('-e', '--extra_files_path', help="Directory of JBrowse Hub folder") # GFF3 parser.add_argument('--gff3', action='append', help='GFF3 format') @@ -45,12 +52,23 @@ args = parser.parse_args() all_datatype_dictionary = dict() - all_tracks = [] + reference = args.fasta - out_path = args.out - tool_directory = 'JBrowse-1.12.1/bin' - chrom_size = utils.getChromSizes(reference, '../ucsc_tools_340_for_HAC') + genome = 'unknown' + out_path = '.' + extra_files_path = '.' + if args.genome_name: + genome = utils.sanitize_name_path(args.genome_name) + if args.out: + out_path = args.out + if args.extra_files_path: + extra_files_path = utils.sanitize_name_path(args.extra_files_path) + cwd = os.getcwd() + #tool_directory not work for Galaxy tool, all tools need to exist in the current PATH, deal with it with tool dependencies + tool_directory = os.path.join(cwd, 'JBrowse-1.12.1/bin') + chrom_size = utils.getChromSizes(reference, tool_directory) + all_tracks = trackObject.trackObject(chrom_size.name, genome, extra_files_path) #store converted files in the array: all_tracks.tracks array_inputs_bam = args.bam array_inputs_bed_simple_repeats = args.bedSimpleRepeats array_inputs_bed_splice_junctions = args.bedSpliceJunctions @@ -77,21 +95,19 @@ for datatype, inputfiles in all_datatype_dictionary.items(): try: - user_input = inputfiles - if not user_input: + if not inputfiles: raise ValueError('empty input, must provide track files!\n') except IOError: print 'Cannot open', datatype else: for f in inputfiles: - track = trackObject.trackObject(f, datatype, chrom_size.name) - track.addToRaw() - all_tracks.append(track) + all_tracks.addToRaw(f, datatype) - jbrowseHub = TrackHub.TrackHub(all_tracks, reference, out_path, tool_directory) + jbrowseHub = TrackHub.TrackHub(all_tracks, reference, out_path, tool_directory, genome, extra_files_path) jbrowseHub.createHub() - - + + + ''' if reference: p = subprocess.Popen(['JBrowse-1.12.1/bin/prepare-refseqs.pl', '--fasta', reference, '--out', out_path])