Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pydeeptools/deeptools/alignmentSieve2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from deeptools import parserCommon
from deeptools.hp import r_alignmentsieve
from deeptools.parserCommon import existingFile


def parseArguments():
Expand All @@ -18,6 +19,7 @@ def parseArguments():
required.add_argument('--bam', '-b',
metavar='FILE1',
help='An indexed BAM file.',
type=existingFile,
required=True)

required.add_argument('--outFile', '-o',
Expand Down Expand Up @@ -122,6 +124,7 @@ def parseArguments():
metavar="BED file",
nargs="+",
default="None",
type=existingFile,
required=False)

filtering.add_argument('--ignoreDuplicates',
Expand Down
3 changes: 3 additions & 0 deletions pydeeptools/deeptools/bamCompare2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from deeptools import parserCommon
from deeptools.hp import r_bamcompare
from deeptools.parserCommon import existingFile


def parseArguments():
Expand Down Expand Up @@ -51,12 +52,14 @@ def getRequiredArgs():
metavar='BAM file',
help='Sorted BAM file 1. Usually the BAM file '
'for the treatment.',
type=existingFile,
required=True)

required.add_argument('--bamfile2', '-b2',
metavar='BAM file',
help='Sorted BAM file 2. Usually the BAM '
'file for the control.',
type=existingFile,
required=True)

return parser
Expand Down
2 changes: 2 additions & 0 deletions pydeeptools/deeptools/bamCoverage2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from deeptools import parserCommon
from deeptools.hp import r_bamcoverage
from deeptools.parserCommon import existingFile


def parseArguments():
Expand Down Expand Up @@ -45,6 +46,7 @@ def get_required_args():
required.add_argument('--bam', '-b',
help='BAM file to process',
metavar='BAM file',
type=existingFile,
required=True)

return parser
Expand Down
4 changes: 3 additions & 1 deletion pydeeptools/deeptools/bamPEFragmentSize.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from deeptools import matplotlib_defaults # noqa: F401
from deeptools.getFragmentAndReadSize import get_read_and_fragment_length
from deeptools.parserCommon import writableFile
from deeptools.parserCommon import existingFile, writableFile


def parse_arguments():
Expand All @@ -30,6 +30,7 @@ def parse_arguments():
help="List of BAM files to process",
nargs="+",
metavar="bam files",
type=existingFile,
)

parser.add_argument(
Expand Down Expand Up @@ -114,6 +115,7 @@ def parse_arguments():
"-bl",
help="A BED file containing regions that should be excluded from all analyses. Currently this works by rejecting genomic chunks that happen to overlap an entry. Consequently, for BAM files, if a read partially overlaps a blacklisted region or a fragment spans over it, then the read/fragment might still be considered.",
metavar="BED file",
type=existingFile,
required=False,
)
parser.add_argument(
Expand Down
2 changes: 2 additions & 0 deletions pydeeptools/deeptools/bigwigAverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np

from deeptools import parserCommon, writeBedGraph_bam_and_bw
from deeptools.parserCommon import existingFile

debug = 0

Expand All @@ -30,6 +31,7 @@ def parse_arguments(args=None):
metavar="Bigwig files",
help="Bigwig files separated by space.",
nargs="+",
type=existingFile,
required=True,
)

Expand Down
3 changes: 3 additions & 0 deletions pydeeptools/deeptools/bigwigCompare.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from deeptools import parserCommon, writeBedGraph_bam_and_bw
from deeptools.getRatio import getRatio
from deeptools.parserCommon import existingFile

debug = 0

Expand All @@ -26,12 +27,14 @@ def parse_arguments(args=None):
metavar='Bigwig file',
help='Bigwig file 1. Usually the file for the '
'treatment.',
type=existingFile,
required=True)

parser.add_argument('--bigwig2', '-b2',
metavar='Bigwig file',
help='Bigwig file 2. Usually the file for the '
'control.',
type=existingFile,
required=True)

parser.add_argument('--scaleFactors',
Expand Down
7 changes: 5 additions & 2 deletions pydeeptools/deeptools/computeMatrix2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from deeptools import parserCommon
from deeptools.hp import r_computematrix
from deeptools.parserCommon import numberOfProcessors, writableFile
from deeptools.parserCommon import existingFile, numberOfProcessors, writableFile


def parse_arguments(args=None):
Expand Down Expand Up @@ -86,6 +86,7 @@ def computeMatrixRequiredArgs(args=None):
"the regions to plot. If multiple bed files are given, each one is considered a "
"group that can be plotted separately.",
nargs="+",
type=existingFile,
required=True,
)
required.add_argument(
Expand All @@ -99,6 +100,7 @@ def computeMatrixRequiredArgs(args=None):
"http://genome.ucsc.edu/goldenPath/help/bigWig.html ",
metavar="File",
nargs="+",
type=existingFile,
required=True,
)
return parser
Expand Down Expand Up @@ -369,7 +371,8 @@ def computeMatrixOptArgs(case=["scale-regions", "reference-point"][0]):
"-bl",
help="A BED file (optionally gzip-compressed) containing regions that should be excluded from all analyses. Filtering is performed at base-pair resolution, so only the portion of a region that overlaps a blacklisted region is excluded.",
metavar="BED file",
default='none',
default='None',
type=existingFile,
required=False,
)

Expand Down
7 changes: 6 additions & 1 deletion pydeeptools/deeptools/computeMatrixOperations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import numpy as np

from deeptools import heatmapper
from deeptools.parserCommon import existingFile


def parse_arguments():
Expand Down Expand Up @@ -153,6 +154,7 @@ def bindArgs():
required.add_argument('--matrixFile', '-m',
help='Matrix files from the computeMatrix tool.',
nargs='+',
type=existingFile,
required=True)

required.add_argument('--outFileName', '-o',
Expand All @@ -168,6 +170,7 @@ def infoArgs():

required.add_argument('--matrixFile', '-m',
help='Matrix file from the computeMatrix tool.',
type=existingFile,
required=True)

return parser
Expand Down Expand Up @@ -259,6 +262,7 @@ def sortArgs():

required.add_argument('--matrixFile', '-m',
help='Matrix file from the computeMatrix tool.',
type=existingFile,
required=True)

required.add_argument('--outFileName', '-o',
Expand All @@ -276,7 +280,8 @@ def sortArgs():
'column with group labels. Note that these should be '
'sorted such that all group entries are together.',
required=True,
nargs='+')
nargs='+',
type=existingFile)

optional = parser.add_argument_group('Optional arguments')

Expand Down
3 changes: 3 additions & 0 deletions pydeeptools/deeptools/estimateReadFiltering.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from deeptools import bamHandler, parserCommon, utilities
from deeptools.mapReduce import mapReduce
from deeptools.parserCommon import existingFile
from deeptools.utilities import smartLabels


Expand Down Expand Up @@ -40,6 +41,7 @@ def parseArguments():
metavar='FILE1 FILE2',
help='List of indexed bam files separated by spaces.',
nargs='+',
type=existingFile,
required=True)

general = parser.add_argument_group('General arguments')
Expand Down Expand Up @@ -147,6 +149,7 @@ def parseArguments():
help="A BED or GTF file containing regions that should be excluded from all analyses. Currently this works by rejecting genomic chunks that happen to overlap an entry. Consequently, for BAM files, if a read partially overlaps a blacklisted region or a fragment spans over it, then the read/fragment might still be considered. Please note that you should adjust the effective genome size, if relevant.",
metavar="BED file",
nargs="+",
type=existingFile,
required=False)

return parser
Expand Down
3 changes: 2 additions & 1 deletion pydeeptools/deeptools/estimateScaleFactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
from importlib.metadata import version

from deeptools.parserCommon import numberOfProcessors
from deeptools.parserCommon import existingFile, numberOfProcessors
from deeptools.SES_scaleFactor import estimateScaleFactor

debug = 0
Expand All @@ -22,6 +22,7 @@ def parseArguments(args=None):
metavar='list of bam files',
help='List of indexed BAM files, space delineated',
nargs='+',
type=existingFile,
required=True)

parser.add_argument('--ignoreForNormalization', '-ignore',
Expand Down
3 changes: 3 additions & 0 deletions pydeeptools/deeptools/multiBamSummary2.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from deeptools import parserCommon
from deeptools.hp import r_mbams
from deeptools.parserCommon import existingFile
from deeptools.utilities import smartLabels


Expand Down Expand Up @@ -108,6 +109,7 @@ def bamcorrelate_args(case="bins"):
metavar="FILE1 FILE2",
help="List of indexed bam files separated by spaces.",
nargs="+",
type=existingFile,
required=True,
)

Expand Down Expand Up @@ -189,6 +191,7 @@ def bamcorrelate_args(case="bins"):
"the regions specified in these files.",
metavar="FILE1.bed FILE2.bed",
nargs="+",
type=existingFile,
required=True,
)

Expand Down
3 changes: 3 additions & 0 deletions pydeeptools/deeptools/multiBigwigSummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import deeptools.getScorePerBigWigBin as score_bw
from deeptools import parserCommon
from deeptools.parserCommon import existingFile
from deeptools.utilities import smartLabels


Expand Down Expand Up @@ -128,6 +129,7 @@ def multiBigwigSummaryArgs(case="bins"):
metavar="FILE1 FILE2",
help="List of bigWig files, separated by spaces.",
nargs="+",
type=existingFile,
required=True,
)

Expand Down Expand Up @@ -216,6 +218,7 @@ def multiBigwigSummaryArgs(case="bins"):
help="Limits the analysis to the regions specified in this file.",
metavar="file1.bed file2.bed",
nargs="+",
type=existingFile,
required=True,
)

Expand Down
14 changes: 13 additions & 1 deletion pydeeptools/deeptools/parserCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ def getParentArgParse(args=None, binSize=True, blackList=True):
help="A BED or GTF file (optionally gzip-compressed) containing regions that should be excluded from all analyses. Filtering is performed at base-pair resolution, so only the portion of a read/fragment that overlaps a blacklisted region is excluded. Please note that you should adjust the effective genome size, if relevant.",
metavar="BED file",
nargs="+",
type=existingFile,
required=False)

optional.add_argument('--numberOfProcessors', '-p',
Expand Down Expand Up @@ -414,6 +415,17 @@ def writableFile(string):
return string


def existingFile(string):
"""
Simple function that checks if a path exists (skip URL, skip 'None' as placeholders for rust code)
"""
if string == "None" or string.startswith(("http://", "https://", "ftp://")):
return string
if not Path(string).is_file():
raise argparse.ArgumentTypeError(f"{string} file does not exist")
return string


"""
Arguments used by heatmapper and profiler
"""
Expand All @@ -424,7 +436,7 @@ def heatmapperMatrixArgs(args=None):
required = parser.add_argument_group('Required arguments')
required.add_argument('--matrixFile', '-m',
help='Matrix file from the computeMatrix tool.',
type=Path,
type=existingFile,
)

required.add_argument('--outFileName', '-out', '-o',
Expand Down
3 changes: 2 additions & 1 deletion pydeeptools/deeptools/plotCorrelation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from deeptools import matplotlib_defaults # noqa: F401
from deeptools.correlation import Correlation
from deeptools.parserCommon import writableFile
from deeptools.parserCommon import existingFile, writableFile


def parse_arguments(args=None):
Expand Down Expand Up @@ -48,6 +48,7 @@ def plot_correlation_args():
required.add_argument('--corData', '-in',
metavar='FILE',
help='Compressed matrix of values generated by multiBigwigSummary or multiBamSummary',
type=existingFile,
required=True)

required.add_argument('--corMethod', '-c',
Expand Down
5 changes: 4 additions & 1 deletion pydeeptools/deeptools/plotCoverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
matplotlib_defaults, # noqa: F401
parserCommon,
)
from deeptools.parserCommon import existingFile
from deeptools.utilities import smartLabels


Expand Down Expand Up @@ -69,6 +70,7 @@ def required_args():
metavar='FILE1 FILE2',
help='List of indexed BAM files separated by spaces.',
nargs='+',
type=existingFile,
required=True)

optional = parser.add_argument_group('Optional arguments')
Expand Down Expand Up @@ -122,7 +124,8 @@ def required_args():
'--outRawCounts or many tens of thousands of regions, as per-base '
'coverage is used!',
metavar='FILE1.bed FILE2.bed',
nargs='+')
nargs='+',
type=existingFile)

optional.add_argument('--outRawCounts',
help='Save raw counts (coverages) to file.',
Expand Down
3 changes: 3 additions & 0 deletions pydeeptools/deeptools/plotEnrichment.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from deeptools.countReadsPerBin import CountReadsPerBin as cr
from deeptools.getFragmentAndReadSize import get_read_and_fragment_length
from deeptools.mapReduce import blSubtract, getUserRegion, mapReduce
from deeptools.parserCommon import existingFile
from deeptools.utilities import getCommonChrNames, getTLen, mungeChromosome, smartLabels


Expand Down Expand Up @@ -57,6 +58,7 @@ def plot_enrichment_args():
metavar='file1.bam file2.bam',
help='List of indexed bam files separated by spaces.',
nargs='+',
type=existingFile,
required=True)

required.add_argument('--BED',
Expand All @@ -67,6 +69,7 @@ def plot_enrichment_args():
'and "peak" for BED files.',
metavar='FILE1.bed FILE2.bed',
nargs='+',
type=existingFile,
required=True)

optional = parser.add_argument_group('Optional arguments')
Expand Down
Loading
Loading