Skip to content

Commit

Permalink
usage and -h for all executables
Browse files Browse the repository at this point in the history
  • Loading branch information
WardDeb committed Aug 22, 2023
1 parent e5a051d commit d7543b1
Show file tree
Hide file tree
Showing 20 changed files with 194 additions and 28 deletions.
3 changes: 2 additions & 1 deletion deeptools/alignmentSieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def parseArguments():
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
description="This tool filters alignments in a BAM/CRAM file according the the specified parameters. It can optionally output to BEDPE format.",
usage='Example usage: alignmentSieve.py -b sample1.bam -o sample1.filtered.bam --minMappingQuality 10 --filterMetrics log.txt')
usage='alignmentSieve -b sample1.bam -o sample1.filtered.bam --minMappingQuality 10 --filterMetrics log.txt\n'
'help: alignmentSieve -h / alignmentSieve --help')

required = parser.add_argument_group('Required arguments')
required.add_argument('--bam', '-b',
Expand Down
3 changes: 2 additions & 1 deletion deeptools/bamCompare.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def parseArguments():
'independently. If this is undesirable, then use the --samFlagInclude '
'or --samFlagExclude options.',

usage=' bamCompare -b1 treatment.bam -b2 control.bam -o log2ratio.bw',
usage='bamCompare -b1 treatment.bam -b2 control.bam -o log2ratio.bw\n'
'help: bamCompare -h / bamCompare --help',

add_help=False)

Expand Down
4 changes: 2 additions & 2 deletions deeptools/bamCoverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def parseArguments():
'Million mapped reads (RPKM), counts per million (CPM), bins per '
'million mapped reads (BPM) and 1x depth (reads per genome '
'coverage, RPGC).\n',
usage='An example usage is:'
'$ bamCoverage -b reads.bam -o coverage.bw',
usage='bamCoverage -b reads.bam -o coverage.bw\n'
'help: bamCoverage -h / bamCoverage --help',
add_help=False)

return parser
Expand Down
9 changes: 8 additions & 1 deletion deeptools/bamPEFragmentSize.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def parse_arguments():
'Properly paired reads are preferred for computation, i.e., '
'it will only use discordant pairs if no concordant alignments '
'overlap with a given region. '
'The default setting simply prints the summary statistics to the screen.')
'The default setting simply prints the summary statistics to the screen.',
usage='bamPEFragmentSize -b sample1.bam sample2.bam -o hist.png\n'
'help: bamPEFragmentSize -h / bamPEFragmentSize --help'
)
parser.add_argument('--bamfiles', '-b',
help='List of BAM files to process',
nargs='+',
Expand Down Expand Up @@ -293,6 +296,10 @@ def printTable(args, fragDict, readDict):
def main(args=None):
args = parse_arguments().parse_args(args)

if len(sys.argv) == 1:
parse_arguments().print_help()
sys.exit()

fraglengths = {}
readlengths = {}
of = None
Expand Down
7 changes: 6 additions & 1 deletion deeptools/bigwigAverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def parse_arguments(args=None):
'of mapped reads. To average the bigWig files, the genome is '
'partitioned into bins of equal size, then the scores '
'in each bigwig file are computed per bin.'
'These scores are averaged and scaleFactors can be applied before the average.')
'These scores are averaged and scaleFactors can be applied before the average.',
usage='bigwigAverage -b sample1.bw sample2.bw -o outfile.bw\n'
'help: bigwigAverage -h / bigwigAverage --help')

# define the arguments
parser.add_argument('--bigwigs', '-b',
Expand Down Expand Up @@ -94,6 +96,9 @@ def average(tileCoverage, args):

def main(args=None):
args = parse_arguments().parse_args(args)
if len(sys.argv) == 1:
parse_arguments().print_help()
sys.exit()

nFiles = len(args.bigwigs)

Expand Down
4 changes: 3 additions & 1 deletion deeptools/bigwigCompare.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def parse_arguments(args=None):
'partitioned into bins of equal size, then the number of reads found '
'in each BAM file are counted per bin and finally a summary '
'value is reported. This value can be the ratio of the number of reads'
'per bin, the log2 of the ratio, the sum or the difference.')
'per bin, the log2 of the ratio, the sum or the difference.',
usage='bigwigCompare -b1 sample1.bw -b2 sample2.bw -o log2.bw\n'
'help: bigwigCompare -h / bigwigCompare --help')

# define the arguments
parser.add_argument('--bigwig1', '-b1',
Expand Down
5 changes: 3 additions & 2 deletions deeptools/computeGCBias.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ def parse_arguments(args=None):
'[Benjamini & Speed (2012). Nucleic Acids Research, 40(10). doi: 10.1093/nar/gks001]. '
'The GC-bias is visualized and the resulting table can be used to'
'correct the bias with `correctGCBias`.',
usage='\n computeGCBias '
'-b file.bam --effectiveGenomeSize 2150570000 -g mm9.2bit -l 200 --GCbiasFrequenciesFile freq.txt [options]',
usage='computeGCBias '
'-b file.bam --effectiveGenomeSize 2150570000 -g mm9.2bit -l 200 --GCbiasFrequenciesFile freq.txt\n'
'help: computeGCBias -h / computeGCBias --help',
conflict_handler='resolve',
add_help=False)

Expand Down
4 changes: 4 additions & 0 deletions deeptools/computeMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,10 @@ def computeMatrixOptArgs(case=['scale-regions', 'reference-point'][0]):
def process_args(args=None):
args = parse_arguments().parse_args(args)

if len(sys.argv) == 1:
parse_arguments().print_help()
sys.exit()

if args.quiet is True:
args.verbose = False

Expand Down
8 changes: 4 additions & 4 deletions deeptools/correctGCBias.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
Expand Down Expand Up @@ -38,10 +38,10 @@ def parse_arguments(args=None):
'(typically AT-rich regions). '
'The tool ``computeGCBias`` needs to be run first to generate the '
'frequency table needed here.',
usage='An example usage is:\n correctGCBias '
usage='correctGCBias '
'-b file.bam --effectiveGenomeSize 2150570000 -g mm9.2bit '
'--GCbiasFrequenciesFile freq.txt -o gc_corrected.bam '
'[options]',
'--GCbiasFrequenciesFile freq.txt -o gc_corrected.bam\n'
'help: correctGCBias -h / correctGCBias --help',
conflict_handler='resolve',
add_help=False)
return parser
Expand Down
4 changes: 3 additions & 1 deletion deeptools/estimateReadFiltering.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def parseArguments():
The sum of these may be more than the total number of reads. Note that alignments are sampled from bins of size --binSize spaced --distanceBetweenBins apart.
""",
usage='Example usage: estimateReadFiltering.py -b sample1.bam sample2.bam > log.txt')
usage='estimateReadFiltering -b sample1.bam sample2.bam\n'
'help: estimateReadFiltering -h / estimateReadFiltering --help'
)

required = parser.add_argument_group('Required arguments')
required.add_argument('--bamfiles', '-b',
Expand Down
117 changes: 117 additions & 0 deletions deeptools/estimateScaleFactor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import deeptools.misc
import argparse
import sys

from deeptools.SES_scaleFactor import estimateScaleFactor
from deeptools.parserCommon import numberOfProcessors
try: # keep python 3.7 support.
from importlib.metadata import version
except ModuleNotFoundError:
from importlib_metadata import version

debug = 0


def parseArguments(args=None):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description='Given two BAM files, this estimates scaling factors '
'(bigger to smaller).',
usage='estimateScaleFactor -b sample1.bam sample2.bam\n'
'help: estimateScaleFactor -h / estimateScaleFactor --help'
)

# define the arguments
parser.add_argument('--bamfiles', '-b',
metavar='list of bam files',
help='List of indexed BAM files, space delineated',
nargs='+',
required=True)


parser.add_argument('--ignoreForNormalization', '-ignore',
help='A comma-separated list of chromosome names, '
'limited by quotes, '
'containing those '
'chromosomes that should be excluded '
'during normalization computations. For example, '
'--ignoreForNormalization "chrX, chrM" ')

parser.add_argument('--sampleWindowLength', '-l',
help='Length in bases for a window used to '
'sample the genome and compute the size or scaling '
'factors',
default=1000,
type=int)

parser.add_argument('--numberOfSamples', '-n',
help='Number of samplings taken from the genome '
'to compute the scaling factors',
default=100000,
type=int)

parser.add_argument('--normalizationLength', '-nl',
help='By default, data is normalized to 1 '
'fragment per 100 bases. The expected value is an '
'integer. For example, if normalizationLength '
'is 1000, then the resulting scaling factor '
'will cause the average coverage of the BAM file to '
'have on average 1 fragment per kilobase',
type=int,
default=10)

parser.add_argument('--skipZeros',
help='If set, then zero counts that happen for *all* '
'BAM files given are ignored. This will result in a '
'reduced number of read counts than that specified '
'in --numberOfSamples',
action='store_true',
required=False)

parser.add_argument('--numberOfProcessors', '-p',
help='Number of processors to use. The default is '
'to use half the maximum number of processors.',
metavar="INT",
type=numberOfProcessors,
default="max/2",
required=False)

parser.add_argument('--verbose', '-v',
help='Set to see processing messages.',
action='store_true')

parser.add_argument('--version', action='version',
version='%(prog)s {}'.format(version('deeptools')))

args=parser.parse_args(args)
if args.ignoreForNormalization:
args.ignoreForNormalization=[x.strip() for x in args.ignoreForNormalization.split(',')]
else:
args.ignoreForNormalization = []
return args

def main(args=None):
"""
The algorithm samples the genome a number of times as specified
by the --numberOfSamples parameter to estimate scaling factors of
between to samples
"""
args = parseArguments().parse_args(args)
if len(args.bamfiles) > 2:
print("SES method to estimate scale factors only works for two samples")
exit(0)

sys.stderr.write("{:,} number of samples will be computed.\n".format(args.numberOfSamples))
sizeFactorsDict = estimateScaleFactor(args.bamfiles, args.sampleWindowLength,
args.numberOfSamples,
args.normalizationLength,
numberOfProcessors=args.numberOfProcessors,
chrsToSkip=args.ignoreForNormalization,
verbose=args.verbose)

for k, v in sizeFactorsDict.items():
print("{}: {}".format(k, v))
12 changes: 9 additions & 3 deletions deeptools/multiBamSummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def parse_arguments(args=None):
add_help=False,
usage='%(prog)s '
'--bamfiles file1.bam file2.bam '
'-o results.npz \n')
'-o results.npz \n'
'help: multiBamSummary bins -h / multiBamSummary bins --help\n')

# BED file arguments
subparsers.add_parser(
Expand All @@ -87,7 +88,8 @@ def parse_arguments(args=None):
"that should be considered for the coverage analysis. A "
"common use is to compare ChIP-seq coverages between two "
"different samples for a set of peak regions.",
usage='%(prog)s --BED selection.bed --bamfiles file1.bam file2.bam -o results.npz\n',
usage='%(prog)s --BED selection.bed --bamfiles file1.bam file2.bam -o results.npz\n'
'help: multiBamSummary BED-file -h / multiBamSummary bins --help\n',
add_help=False)

return parser
Expand Down Expand Up @@ -194,7 +196,11 @@ def bamcorrelate_args(case='bins'):

def process_args(args=None):
args = parse_arguments().parse_args(args)


if len(sys.argv) == 1:
parse_arguments().print_help()
sys.exit()

if args.labels and len(args.bamfiles) != len(args.labels):
print("The number of labels does not match the number of bam files.")
exit(0)
Expand Down
10 changes: 8 additions & 2 deletions deeptools/multiBigwigSummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def parse_arguments(args=None):
add_help=False,
usage='multiBigwigSummary bins '
'-b file1.bw file2.bw '
'-o results.npz\n')
'-o results.npz\n'
'help: multiBigwigSummary bins -h / multiBigwigSummary bins --help\n')

# BED file arguments
subparsers.add_parser(
Expand All @@ -89,14 +90,19 @@ def parse_arguments(args=None):
"different samples over a set of pre-defined peak regions.",
usage='multiBigwigSummary BED-file '
'-b file1.bw file2.bw '
'-o results.npz --BED selection.bed\n',
'-o results.npz --BED selection.bed\n'
'help: multiBigwigSummary BED-file -h / multiBigwigSummary BED-file --help\n',
add_help=False)

return parser


def process_args(args=None):
args = parse_arguments().parse_args(args)

if len(sys.argv) == 1:
parse_arguments().print_help()
sys.exit()

if not args.labels and args.smartLabels:
args.labels = smartLabels(args.bwfiles)
Expand Down
4 changes: 3 additions & 1 deletion deeptools/plotCorrelation.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def parse_arguments(args=None):
epilog='example usages:\n'
'plotCorrelation -in results_file --whatToPlot heatmap --corMethod pearson -o heatmap.png\n\n'
' \n\n',
parents=[basic_args, heatmap_parser, scatter_parser])
parents=[basic_args, heatmap_parser, scatter_parser],
usage='plotCorrelation -in matrix.gz -c spearman -p heatmap -o plot.png\n'
'help: plotCorrelation -h / plotCorrelation --help\n')

return parser

Expand Down
4 changes: 3 additions & 1 deletion deeptools/plotCoverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def parse_arguments(args=None):
epilog='example usages:\nplotCoverage '
'--bamfiles file1.bam file2.bam -o results.png\n\n'
' \n\n',
conflict_handler='resolve')
conflict_handler='resolve',
usage='plotCoverage -b sample1.bam sample2.bam -o coverage.png \n'
'help: plotCoverage -h / plotCoverage --help\n')

parser.add_argument('--version', action='version',
version='plotCoverage {}'.format(version('deeptools')))
Expand Down
4 changes: 3 additions & 1 deletion deeptools/plotEnrichment.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def parse_arguments(args=None):
epilog='example usages:\n'
'plotEnrichment -b file1.bam file2.bam --BED peaks.bed -o enrichment.png\n\n'
' \n\n',
parents=[basic_args, parent_parser, read_options])
parents=[basic_args, parent_parser, read_options],
usage='plotEnrichment -b sample1.bam sample2.bam --BED peaks.bed -o enrichment.png\n'
'help: plotEnrichment -h / plotEnrichment --help\n')

return parser

Expand Down
6 changes: 4 additions & 2 deletions deeptools/plotFingerprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ def parse_arguments(args=None):
'these counts are sorted '
'and the cumulative sum is finally plotted. ',
conflict_handler='resolve',
usage='An example usage is: plotFingerprint -b treatment.bam control.bam '
'-plot fingerprint.png',
usage='plotFingerprint -b treatment.bam control.bam '
'-plot fingerprint.png\n'
'help: plotFingerprint -h / plotFingerprint --help'
,
add_help=False)

return parser
Expand Down
4 changes: 3 additions & 1 deletion deeptools/plotHeatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def parse_arguments(args=None):
'scores associated with genomic regions. '
'The program requires a matrix file '
'generated by the tool ``computeMatrix``.',
epilog='An example usage is: plotHeatmap -m <matrix file>',
epilog='An example usage is: plotHeatmap -m matrix.gz',
usage='plotHeatmap -m matrix.gz\n'
'help: plotHeatmap -h / plotHeatmap --help',
add_help=False)

return parser
Expand Down
4 changes: 3 additions & 1 deletion deeptools/plotPCA.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def parse_arguments(args=None):
epilog='example usages:\n'
'plotPCA -in coverages.npz -o pca.png\n\n'
' \n\n',
parents=[basic_args, ])
parents=[basic_args, ],
usage='plotPCA -in coverage.npz -o pca.png\n',
'help: plotPCA -h / plotPCA --help\n')
return parser


Expand Down
Loading

0 comments on commit d7543b1

Please sign in to comment.