[med-svn] [fastaq] 05/05: Changes to rules file and to usage_to_man to create automated man pages under make. Added a patch to change the upstream code in order to allow the man pages to be created automatically

Jorge Soares jssoares-guest at moszumanska.debian.org
Wed Oct 15 14:52:49 UTC 2014


This is an automated email from the git hooks/post-receive script.

jssoares-guest pushed a commit to branch master
in repository fastaq.

commit 4822f8132be414a2d4df5d0a1e8cc4b56a5f7a92
Author: Jorge Soares <j.s.soares at gmail.com>
Date:   Wed Oct 15 15:52:31 2014 +0100

    Changes to rules file and to usage_to_man to create automated man pages under make. Added a patch to change the upstream code in order to allow the man pages to be created automatically
---
 ...ay-import-statements-for-manpage-creation.patch | 727 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 debian/rules                                       |   6 +-
 debian/usage_to_man                                |  72 +-
 4 files changed, 775 insertions(+), 31 deletions(-)

diff --git a/debian/patches/delay-import-statements-for-manpage-creation.patch b/debian/patches/delay-import-statements-for-manpage-creation.patch
new file mode 100644
index 0000000..f7d6bc8
--- /dev/null
+++ b/debian/patches/delay-import-statements-for-manpage-creation.patch
@@ -0,0 +1,727 @@
+From: Jorge Soares <j.s.soares at gmail.com>
+Subject: Delayed import of API modules to allow for automated manpage creation with help2man.
+
+Origin: upstream, https://github.com/sanger-pathogens/Fastaq.git
+
+Delayed import of API modules to allow for automated manpage creation with help2man.
+For help2man to work the modules provided by this package would need to be already installed.
+Delaying the import step of this package's modules was the most pragmatic approach to this problem.
+
+--- a/scripts/fastaq_capillary_to_pairs
++++ b/scripts/fastaq_capillary_to_pairs
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Given a fasta/q file of capillary reads, makes an interleaved file of read pairs (where more than read from same ligation, takes the longest read) and a file of unpaired reads. Replaces the .p1k/.q1k part of read names to denote fwd/rev reads with /1 and /2',
+@@ -9,4 +8,8 @@
+ parser.add_argument('infile', help='Name of input fasta/q file')
+ parser.add_argument('outprefix', help='Prefix of output files', metavar='outfiles prefix')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.capillary_to_pairs(options.infile, options.outprefix)
+--- a/scripts/fastaq_chunker
++++ b/scripts/fastaq_chunker
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Splits a multi fasta/q file into separate files. Splits sequences into chunks of a fixed size. Aims for chunk_size chunks in each file, but allows a little extra, so chunk can be up to (chunk_size + tolerance), to prevent tiny chunks made from the ends of sequences',
+@@ -12,6 +11,10 @@
+ parser.add_argument('tolerance', type=int, help='Tolerance allowed in chunk size')
+ parser.add_argument('--skip_all_Ns', action='store_true', help='Do not output any sequence that consists of all Ns')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.split_by_fixed_size(
+     options.infile,
+     options.outprefix,
+--- a/scripts/fastaq_count_sequences
++++ b/scripts/fastaq_count_sequences
+@@ -1,11 +1,14 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Counts the number of sequences in a fasta/q file',
+     usage = '%(prog)s <fasta/q in>')
+ parser.add_argument('infile', help='Name of input fasta/q file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ print(tasks.count_sequences(options.infile))
+--- a/scripts/fastaq_deinterleave
++++ b/scripts/fastaq_deinterleave
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Deinterleaves fasta/q file, so that reads are written alternately between two output files',
+@@ -11,4 +10,8 @@
+ parser.add_argument('out_fwd', help='Name of output fasta/q file of forwards reads')
+ parser.add_argument('out_rev', help='Name of output fasta/q file of reverse reads')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.deinterleave(options.infile, options.out_fwd, options.out_rev, fasta_out=options.fasta_out)
+--- a/scripts/fastaq_enumerate_names
++++ b/scripts/fastaq_enumerate_names
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Renames sequences in a file, calling them 1,2,3... etc',
+@@ -12,6 +11,10 @@
+ parser.add_argument('infile', help='Name of fasta/q file to be read')
+ parser.add_argument('outfile', help='Name of output fasta/q file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.enumerate_names(options.infile,
+                       options.outfile,
+                       start_index=options.start_index,
+--- a/scripts/fastaq_expand_nucleotides
++++ b/scripts/fastaq_expand_nucleotides
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Makes all combinations of sequences in input file by using all possibilities of redundant bases. e.g. ART could be AAT or AGT. Assumes input is nucleotides, not amino acids',
+@@ -9,6 +8,10 @@
+ parser.add_argument('infile', help='Name of input file. Can be any of FASTA, FASTQ, GFF3, EMBL, GBK, Phylip')
+ parser.add_argument('outfile', help='Name of output file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.expand_nucleotides(
+     options.infile,
+     options.outfile,
+--- a/scripts/fastaq_extend_gaps
++++ b/scripts/fastaq_extend_gaps
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Extends the length of all gaps (and trims the start/end of sequences) in a fasta/q file. Does this by replacing a set number of bases either side of each gap with Ns. Any sequence that ends up as all Ns is lost',
+@@ -10,4 +9,8 @@
+ parser.add_argument('infile', help='Name of input fasta/q file')
+ parser.add_argument('outfile', help='Name of output fasta/q file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.extend_gaps(options.infile, options.outfile, options.trim_number)
+--- a/scripts/fastaq_fasta_to_fastq
++++ b/scripts/fastaq_fasta_to_fastq
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Given a fasta and qual file, makes a fastq file',
+@@ -10,4 +9,8 @@
+ parser.add_argument('qual', help='Name of input quality scores file', metavar='qual in')
+ parser.add_argument('outfile', help='Name of output fastq file', metavar='fastq out')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.fasta_to_fastq(options.fasta, options.qual, options.outfile)
+--- a/scripts/fastaq_filter
++++ b/scripts/fastaq_filter
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Filters a fasta/q file by sequence length and/or by name matching a regular expression',
+@@ -14,6 +13,10 @@
+ parser.add_argument('infile', help='Name of fasta/q file to be filtered')
+ parser.add_argument('outfile', help='Name of output fasta/q file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.filter(options.infile,
+              options.outfile,
+              minlength=options.min_length,
+--- a/scripts/fastaq_get_ids
++++ b/scripts/fastaq_get_ids
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Gets IDs from each sequence in a fasta or fastq file',
+@@ -9,4 +8,8 @@
+ parser.add_argument('infile', help='Name of input fasta/q file')
+ parser.add_argument('outfile', help='Name of output file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.get_ids(options.infile, options.outfile)
+--- a/scripts/fastaq_get_seq_flanking_gaps
++++ b/scripts/fastaq_get_seq_flanking_gaps
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Gets the sequences either side of gaps in a fasta/q file',
+@@ -11,4 +10,8 @@
+ parser.add_argument('infile', help='Name of input fasta/q file')
+ parser.add_argument('outfile', help='Name of output fasta/q file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.get_seqs_flanking_gaps(options.infile, options.outfile, options.left, options.right)
+--- a/scripts/fastaq_insert_or_delete_bases
++++ b/scripts/fastaq_insert_or_delete_bases
+@@ -1,9 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-import sys
+-import random
+-from fastaq import sequences, utils, intervals
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Deletes or inserts bases at given position(s) from a fasta/q file',
+@@ -16,6 +13,11 @@
+ parser.add_argument('--insert_range', help='Inserts random bases starting after position P in each sequence of the input file. Inserts start + (n-1)*step bases into sequence n.', metavar='P,start,step')
+ options = parser.parse_args()
+ 
++
++import sys
++import random
++from fastaq import sequences, utils, intervals
++
+ test_ops = [int(x is not None) for x in [options.delete, options.insert, options.delete_range, options.insert_range]]
+ 
+ if sum(test_ops) != 1:
+--- a/scripts/fastaq_interleave
++++ b/scripts/fastaq_interleave
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Interleaves two fasta/q files, so that reads are written alternately first/second in output file',
+@@ -10,4 +9,8 @@
+ parser.add_argument('infile_2', help='Name of second input fasta/q file')
+ parser.add_argument('outfile', help='Name of output fasta/q file of interleaved reads')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.interleave(options.infile_1, options.infile_2, options.outfile)
+--- a/scripts/fastaq_long_read_simulate
++++ b/scripts/fastaq_long_read_simulate
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Simulates long reads from a fasta/q file. Can optionally make insertions into the reads, like pacbio does. If insertions made, coverage calculation is done before the insertions (so total read length may appear longer then expected).',
+@@ -16,7 +15,6 @@
+ parser.add_argument('--fixed_read_length', type=int, help='Length of each read. Only applies if method is tile or uniform. [%(default)s]', default=20000, metavar='INT')
+ parser.add_argument('--coverage', type=float, help='Read coverage. Only applies if method is gamma or uniform. [%(default)s]', default=2, metavar='FLOAT')
+ 
+-
+ tiling_group = parser.add_argument_group('tiling options')
+ tiling_group.add_argument('--tile_step', type=int, help='Distance between start of each read [%(default)s]', default=10000, metavar='INT')
+ 
+@@ -29,8 +27,11 @@
+ ins_group.add_argument('--ins_skip', type=int, help='Insert a random base every --skip bases plus or minus --ins_window. If this option is used, must also use --ins_window.', metavar='INT')
+ ins_group.add_argument('--ins_window', type=int, help='See --ins_skip. If this option is used, must also use --ins_skip.', metavar='INT')
+ 
+-
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.make_long_reads(
+     options.infile,
+     options.outfile,
+--- a/scripts/fastaq_make_random_contigs
++++ b/scripts/fastaq_make_random_contigs
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Makes a multi-fasta file of random sequences, all of the same length. Each base has equal chance of being A,C,G or T',
+@@ -14,6 +13,10 @@
+ parser.add_argument('length', type=int, help='Length of each contig')
+ parser.add_argument('outfile', help='Name of output file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.make_random_contigs(
+     options.contigs,
+     options.length,
+--- a/scripts/fastaq_merge
++++ b/scripts/fastaq_merge
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Converts multi fasta/q file to single sequence file, preserving original order of sequences',
+@@ -10,6 +9,10 @@
+ parser.add_argument('outfile', help='Name of output file')
+ parser.add_argument('-n', '--name', help='Name of sequence in output file [%(default)s]', default='union')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.merge_to_one_seq(
+     options.infile,
+     options.outfile,
+--- a/scripts/fastaq_replace_bases
++++ b/scripts/fastaq_replace_bases
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Replaces all occurences of one letter with another in a fasta/q file',
+@@ -11,4 +10,8 @@
+ parser.add_argument('old', help='Base to be replaced')
+ parser.add_argument('new', help='Replace with this letter')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.replace_bases(options.infile, options.outfile, options.old, options.new)
+--- a/scripts/fastaq_reverse_complement
++++ b/scripts/fastaq_reverse_complement
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Reverse complements all sequences in a fasta/q file',
+@@ -9,4 +8,8 @@
+ parser.add_argument('infile', help='Name of input fasta/q file')
+ parser.add_argument('outfile', help='Name of output fasta/q file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.reverse_complement(options.infile, options.outfile)
+--- a/scripts/fastaq_scaffolds_to_contigs
++++ b/scripts/fastaq_scaffolds_to_contigs
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Creates a file of contigs from a file of scaffolds - i.e. breaks at every gap in the input',
+@@ -10,4 +9,8 @@
+ parser.add_argument('infile', help='Name of input fasta/q file')
+ parser.add_argument('outfile', help='Name of output contigs file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.scaffolds_to_contigs(options.infile, options.outfile, number_contigs=options.number_contigs)
+--- a/scripts/fastaq_search_for_seq
++++ b/scripts/fastaq_search_for_seq
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Searches for an exact match on a given string and its reverese complement, in every sequences of a fasta/q file. Case insensitive. Guaranteed to find all hits',
+@@ -10,4 +9,8 @@
+ parser.add_argument('outfile', help='Name of outputfile. Tab-delimited output: sequence name, position, strand')
+ parser.add_argument('search_string', help='String to search for in the sequences')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.search_for_seq(options.infile, options.outfile, options.search_string)
+--- a/scripts/fastaq_sequence_trim
++++ b/scripts/fastaq_sequence_trim
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Trims sequences off the start of all sequences in a pair of fasta/q files, whenever there is a perfect match. Only keeps a read pair if both reads of the pair are at least a minimum length after any trimming',
+@@ -13,6 +12,10 @@
+ parser.add_argument('outfile_2', help='Name of output reverse fasta/q file', metavar='out_2')
+ parser.add_argument('trim_seqs', help='Name of fasta/q file of sequences to search for at the start of each input sequence', metavar='trim_seqs')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.sequence_trim(
+     options.infile_1,
+     options.infile_2,
+--- a/scripts/fastaq_split_by_base_count
++++ b/scripts/fastaq_split_by_base_count
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Splits a multi fasta/q file into separate files. Does not split sequences. Puts up to max_bases into each split file. The exception is that any sequence longer than max_bases is put into its own file.',
+@@ -10,6 +9,9 @@
+ parser.add_argument('outprefix', help='Name of output fasta/q file')
+ parser.add_argument('max_bases', type=int, help='Max bases in each output split file', metavar='max_bases')
+ parser.add_argument('--max_seqs', type=int, help='Max number of sequences in each output split file [no limit]', metavar='INT')
+-
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.split_by_base_count(options.infile, options.outprefix, options.max_bases, options.max_seqs)
+--- a/scripts/fastaq_strip_illumina_suffix
++++ b/scripts/fastaq_strip_illumina_suffix
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Strips /1 or /2 off the end of every read name in a fasta/q file',
+@@ -9,4 +8,8 @@
+ parser.add_argument('infile', help='Name of input fasta/q file')
+ parser.add_argument('outfile', help='Name of output fasta/q file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.strip_illumina_suffix(options.infile, options.outfile)
+--- a/scripts/fastaq_to_fake_qual
++++ b/scripts/fastaq_to_fake_qual
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Makes fake quality scores file from a fasta/q file',
+@@ -10,6 +9,10 @@
+ parser.add_argument('outfile', help='Name of output file')
+ parser.add_argument('-q', '--qual', type=int, help='Quality score to assign to all bases [%(default)s]', default=40)
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.fastaq_to_fake_qual(
+     options.infile,
+     options.outfile,
+--- a/scripts/fastaq_to_fasta
++++ b/scripts/fastaq_to_fasta
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Converts sequence file to FASTA format',
+@@ -11,6 +10,10 @@
+ parser.add_argument('-l', '--line_length', type=int, help='Number of bases on each sequence line of output file [%(default)s]', default=60)
+ parser.add_argument('-s', '--strip_after_whitespace', action='store_true', help='Remove everything after first whitesapce in every sequence name')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.to_fasta(
+     options.infile,
+     options.outfile,
+--- a/scripts/fastaq_to_mira_xml
++++ b/scripts/fastaq_to_mira_xml
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Creates an xml file from a fasta/q file of reads, for use with Mira assembler',
+@@ -9,4 +8,8 @@
+ parser.add_argument('infile', help='Name of input fasta/q file')
+ parser.add_argument('xml_out', help='Name of output xml file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.fastaq_to_mira_xml(options.infile, options.xml_out)
+--- a/scripts/fastaq_to_orfs_gff
++++ b/scripts/fastaq_to_orfs_gff
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Writes a GFF file of open reading frames from a fasta/q file',
+@@ -10,4 +9,8 @@
+ parser.add_argument('infile', help='Name of input fasta/q file')
+ parser.add_argument('gff_out', help='Name of output gff file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.fastaq_to_orfs_gff(options.infile, options.gff_out, min_length=options.min_length)
+--- a/scripts/fastaq_to_perfect_reads
++++ b/scripts/fastaq_to_perfect_reads
+@@ -1,10 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-import random
+-from math import floor, ceil
+-from fastaq import sequences, utils
+-import sys
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Makes perfect paired end fastq reads from a fasta/q file, with insert sizes sampled from a normal distribution. Read orientation is innies. Output is an interleaved fastq file.',
+@@ -20,6 +16,12 @@
+ parser.add_argument('--seed', type=int, help='Seed for random number generator. Default is to use python\'s default', default=None, metavar='INT')
+ options = parser.parse_args()
+ 
++
++import random
++from math import floor, ceil
++from fastaq import sequences, utils
++import sys
++
+ random.seed(a=options.seed)
+ 
+ seq_reader = sequences.file_reader(options.infile)
+--- a/scripts/fastaq_to_quasr_primers_file
++++ b/scripts/fastaq_to_quasr_primers_file
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Converts a fasta/q file to QUASR primers format: just the sequence on each line and its reverse complement, tab separated',
+@@ -9,4 +8,8 @@
+ parser.add_argument('infile', help='Name of input fasta/q file')
+ parser.add_argument('outfile', help='Name of output file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.to_quasr_primers(options.infile, options.outfile)
+--- a/scripts/fastaq_to_random_subset
++++ b/scripts/fastaq_to_random_subset
+@@ -1,9 +1,6 @@
+ #!/usr/bin/env python3
+ 
+-import sys
+ import argparse
+-import random
+-from fastaq import sequences, utils
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Takes a random subset of reads from a fasta/q file and optionally the corresponding read ' +
+@@ -15,6 +12,11 @@
+ parser.add_argument('probability', type=int, help='Probability of keeping any given read (pair) in [0,100]', metavar='INT')
+ options = parser.parse_args()
+ 
++
++import sys
++import random
++from fastaq import sequences, utils
++
+ seq_reader = sequences.file_reader(options.infile)
+ fout = utils.open_file_write(options.outfile)
+ 
+--- a/scripts/fastaq_to_tiling_bam
++++ b/scripts/fastaq_to_tiling_bam
+@@ -1,9 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-import sys
+-import os
+-from fastaq import sequences, utils
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Takes a fasta/q file. Makes a BAM file containing perfect (unpaired) reads tiling the whole genome',
+@@ -17,6 +14,11 @@
+ parser.add_argument('--read_group', help='Add the given read group ID to all reads [%(default)s]' ,default='42')
+ options = parser.parse_args()
+ 
++
++import sys
++import os
++from fastaq import sequences, utils
++
+ # make a header first  - we need to add the @RG line to the default header made by samtools
+ tmp_empty_file = options.outfile + '.tmp.empty'
+ f = utils.open_file_write(tmp_empty_file)
+--- a/scripts/fastaq_to_unique_by_id
++++ b/scripts/fastaq_to_unique_by_id
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Removes duplicate sequences from a fasta/q file, based on their names. If the same name is found more than once, then the longest sequence is kept. Order of sequences is preserved in output',
+@@ -9,4 +8,8 @@
+ parser.add_argument('infile', help='Name of input fasta/q file')
+ parser.add_argument('outfile', help='Name of output fasta/q file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.to_unique_by_id(options.infile, options.outfile)
+--- a/scripts/fastaq_translate
++++ b/scripts/fastaq_translate
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Translates all sequences in a fasta or fastq file. Output is always fasta format',
+@@ -10,4 +9,8 @@
+ parser.add_argument('infile', help='Name of fasta/q file to be translated', metavar='in.fasta/q')
+ parser.add_argument('outfile', help='Name of output fasta file', metavar='out.fasta')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.translate(options.infile, options.outfile, frame=options.frame)
+--- a/scripts/fastaq_trim_Ns_at_end
++++ b/scripts/fastaq_trim_Ns_at_end
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Trims any Ns off each sequence in a fasta/q file. Does nothing to gaps in the middle, just trims the ends',
+@@ -9,4 +8,8 @@
+ parser.add_argument('infile', help='Name of input fasta/q file')
+ parser.add_argument('outfile', help='Name of output fasta/q file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.trim_Ns_at_end(options.infile, options.outfile)
+--- a/scripts/fastaq_trim_ends
++++ b/scripts/fastaq_trim_ends
+@@ -1,7 +1,6 @@
+ #!/usr/bin/env python3
+ 
+ import argparse
+-from fastaq import tasks
+ 
+ parser = argparse.ArgumentParser(
+     description = 'Trims set number of bases off each sequence in a fasta/q file',
+@@ -11,4 +10,8 @@
+ parser.add_argument('end_trim', type=int, help='Number of bases to trim off end')
+ parser.add_argument('outfile', help='Name of output fasta/q file')
+ options = parser.parse_args()
++
++
++from fastaq import tasks
++
+ tasks.trim(options.infile, options.outfile, options.start_trim, options.end_trim)
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..dfa3826
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+delay-import-statements-for-manpage-creation.patch
diff --git a/debian/rules b/debian/rules
index a89085c..d3d035e 100755
--- a/debian/rules
+++ b/debian/rules
@@ -3,8 +3,8 @@
 export DH_VERBOSE := 1
 export PYBUILD_NAME=fastaq
 
-sourcedir := $(CURDIR)/man
 mandir := $(CURDIR)/debian/man
+debfolder := $(CURDIR)/debian
 
 %:
 	dh $@ --with python3 --buildsystem=pybuild
@@ -17,9 +17,9 @@ override_dh_auto_build:
 
 override_dh_auto_clean:
 	rm -rf build .pybuild
+	rm -rf man
 
 override_dh_installman:
 	mkdir -p $(mandir)
-	usage_to_man
-	mv $(sourcedir)/*.1 $(mandir)
+	$(debfolder)/usage_to_man
 	dh_installman --
\ No newline at end of file
diff --git a/debian/usage_to_man b/debian/usage_to_man
index 481fd5c..16793ce 100755
--- a/debian/usage_to_man
+++ b/debian/usage_to_man
@@ -3,40 +3,53 @@
 #Converts the Fastaq python scripts usage into man pages
 #The man pages are placed in the man folder of the main Fastaq directory  
 
-source='../scripts'
-destination='../man'
+source='scripts'
+destination='debian/man'
+
+if [ ! -d "$destination" ]; then
+    mkdir $destination
+fi
 
 for i in $source/fastaq_*; do
-    j=$(echo $i | sed "s/$source\///");
-    out_file=$destination/$j.1
-    help2man -m $j -n $j --no-discard-stderr $i |
-    grep -v $j': error: too few arguments' |
-    sed "s/usage://gi" > $out_file;
+    if [ -e $i ]; then
+	echo "Converting $i to man - first pass";
+	j=$(echo $i | sed "s/$source\///");
+	out_file=$destination/$j.1
+
+	help2man -m $j -n $j --no-discard-stderr $i |
+	grep -v $j': error: too few arguments' |
+	sed "s/usage://gi" > $out_file;
+    else
+	echo "File $i does not exist"; exit 1;
+    fi
+
 done
 
 
 
 for file in $destination/*.1; do
 
-    out_file=$(echo $file | sed 's/\.1/\.2/');
-    filename=$(echo $file | sed "s/\($destination\/*\)\([a-zA-Z_0-9]* *\)\.1/\2/")
-    while read line
-    do
-	echo $line |
-	sed "s/\-\s\($filename *\)/\1/" |
-	sed "s/\(.TH *\)\([a-zA-Z_0-9]* *\)\(\"[0-9\"]* *\)\(\"[a-zA-Z0-9_ ]*\" *\)\(\"[a-zA-Z0-9_\<\>\/ ]*\" *\)\(\"[a-zA-Z0-9_]*\" *\)/\1 \2 \6 \3/" |
-	sed "s/\(The\sfull\sdocumentation\sfor*\)/$filename -h will display the original python documentation/" |
-	sed "s/^\.B//" |
-	sed "s/^is\smaintained\sas\sa\sTexinfo\smanual.\sIf\sthe//" |
-	sed "s/^\.B//" |
-	sed "s/\sinfo//" |
-	sed "s/^and//" |
-	sed "s/^programs\sare\sproperly\sinstalled\sat\syour\ssite\,\sthe\scommand//" |
-	sed "s/\(.IP\r*\)//" |
-	sed "s/^should\sgive\syou\saccess\sto\sthe\scomplete\smanual\.//"
-
-    done < $file > $out_file
-cat <<EOF >> $out_file
+    if [ -e $file ]; then
+	echo "Final checks for file  $file - second pass";
+	out_file=$(echo $file | sed 's/\.1/\.2/');
+	filename=$(echo $file | sed "s/\($destination\/*\)\([a-zA-Z_0-9]* *\)\.1/\2/")
+	while read line
+	do
+	    echo $line |
+	    sed "s/\-\s\($filename *\)/\1/" |
+	    sed "s/\(.TH *\)\([a-zA-Z_0-9]* *\)\(\"[0-9\"]* *\)\(\"[a-zA-Z0-9_ ]*\" *\)\(\"[a-zA-Z0-9_\<\>\/ ]*\" *\)\(\"[a-zA-Z0-9_]*\" *\)/\1 \2 \6 \3/" |
+	    sed "s/\(The\sfull\sdocumentation\sfor*\)/$filename -h will display the original python documentation/" |
+	    sed "s/^\.B//" |
+	    sed "s/^is\smaintained\sas\sa\sTexinfo\smanual.\sIf\sthe//" |
+	    sed "s/^\.B//" |
+	    sed "s/\sinfo//" |
+	    sed "s/^and//" |
+	    sed "s/^programs\sare\sproperly\sinstalled\sat\syour\ssite\,\sthe\scommand//" |
+	    sed "s/\(.IP\r*\)//" |
+	    sed "s/^should\sgive\syou\saccess\sto\sthe\scomplete\smanual\.//"
+
+	done < $file > $out_file
+	cat <<EOF >> $out_file
 .SH "AUTHOR"
 .sp
 $filename was originally written by Martin Hunt (mh12 at sanger\&.ac\&.uk)
@@ -45,7 +58,10 @@ $filename was originally written by Martin Hunt (mh12 at sanger\&.ac\&.uk)
 Wellcome Trust Sanger Institute Copyright \(co 2013 Wellcome Trust Sanger Institute This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version\&.
 EOF
 
-    mv $out_file $file
-
+	mv $out_file $file
+	exit 1;
+    else
+	echo "File $file does not exist"; exit 1;
+    fi
 
 done

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/fastaq.git



More information about the debian-med-commit mailing list