Skip to content

Commit

Permalink
drop deepblue support
Browse files Browse the repository at this point in the history
  • Loading branch information
WardDeb committed Nov 23, 2023
1 parent 73d03aa commit 80b646b
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 507 deletions.
11 changes: 11 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
3.5.5
* drop support for python 3.7
* doc fixes (argparse properly displayed, minor changes in installation instructions)
* deepblue support drop

3.5.4
* error handling and cases for bwAverage with >2 samples
* Tick.label deprecation for mpl 3.8
* minimal mpl version is 3.5
* cicd update for pypi push

3.5.3
* requirement cap for matplotlib lifted (changes in plotting can occur)
* nose has been deprecated in favor of pytests
Expand Down
38 changes: 2 additions & 36 deletions deeptools/bigwigAverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
import numpy as np
from deeptools import parserCommon
from deeptools import writeBedGraph_bam_and_bw
import deeptools.deepBlue as db

debug = 0


def parse_arguments(args=None):
parentParser = parserCommon.getParentArgParse()
outputParser = parserCommon.output()
dbParser = parserCommon.deepBlueOptionalArgs()
parser = argparse.ArgumentParser(
parents=[parentParser, outputParser, dbParser],
parents=[parentParser, outputParser],
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description='This tool average multiple bigWig files based on the number '
'of mapped reads. To average the bigWig files, the genome is '
Expand Down Expand Up @@ -59,7 +57,7 @@ def parse_arguments(args=None):

def getType(fname):
"""
Tries to determine if a file is a wiggle file from deepBlue or a bigWig file.
Tries to determine if a file is a wiggle file a bigWig file.
Returns 'wiggle' if the file name ends with .wig, otherwise 'bigwig'
"""
if fname.endswith(".wig") or fname.endswith(".wiggle"):
Expand Down Expand Up @@ -119,29 +117,6 @@ def main(args=None):
FUNC = average
function_args = {'scaleFactors': scaleFactors}

# Preload deepBlue files, which need to then be deleted
deepBlueFiles = []
for idx, fname in enumerate(args.bigwigs):
if db.isDeepBlue(fname):
deepBlueFiles.append([fname, idx])
if len(deepBlueFiles) > 0:
sys.stderr.write("Preloading the following deepBlue files: {}\n".format(",".join([x[0] for x in deepBlueFiles])))
foo = db.deepBlue(deepBlueFiles[0][0], url=args.deepBlueURL, userKey=args.userKey)
regs = db.makeChromTiles(foo)
for x in deepBlueFiles:
x.extend([args, regs])
if len(deepBlueFiles) > 1 and args.numberOfProcessors > 1:
pool = multiprocessing.Pool(args.numberOfProcessors)
res = pool.map_async(db.preloadWrapper, deepBlueFiles).get(9999999)
else:
res = list(map(db.preloadWrapper, deepBlueFiles))

# substitute the file names with the temp files
for (ftuple, r) in zip(deepBlueFiles, res):
args.bigwigs[ftuple[1]] = r
deepBlueFiles = [[x[0], x[1]] for x in deepBlueFiles]
del regs

writeBedGraph_bam_and_bw.writeBedGraph(
[(b, getType(b)) for b in args.bigwigs],
args.outFileName, 0, FUNC,
Expand All @@ -154,12 +129,3 @@ def main(args=None):
smoothLength=False,
missingDataAsZero=not args.skipNonCoveredRegions,
extendPairedEnds=False)

# Clean up temporary bigWig files, if applicable
if not args.deepBlueKeepTemp:
for k, v in deepBlueFiles:
os.remove(args.bigwigs[v])
else:
for k, v in deepBlueFiles:
foo = args.bigwigs[v]
print("{} is stored in {}".format(k, foo))
46 changes: 2 additions & 44 deletions deeptools/bigwigCompare.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
from deeptools import parserCommon
from deeptools.getRatio import getRatio
from deeptools import writeBedGraph_bam_and_bw
import deeptools.deepBlue as db

debug = 0


def parse_arguments(args=None):
parentParser = parserCommon.getParentArgParse()
outputParser = parserCommon.output()
dbParser = parserCommon.deepBlueOptionalArgs()
parser = argparse.ArgumentParser(
parents=[parentParser, outputParser, dbParser],
parents=[parentParser, outputParser],
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description='This tool compares two bigWig files based on the number '
'of mapped reads. To compare the bigWig files, the genome is '
Expand Down Expand Up @@ -104,7 +102,7 @@ def parse_arguments(args=None):

def getType(fname):
"""
Tries to determine if a file is a wiggle file from deepBlue or a bigWig file.
Tries to determine if a file is a wiggle file or a bigWig file.
Returns 'wiggle' if the file name ends with .wig, otherwise 'bigwig'
"""
if fname.endswith(".wig") or fname.endswith(".wiggle"):
Expand Down Expand Up @@ -136,32 +134,6 @@ def main(args=None):
'scaleFactors': scaleFactors,
'pseudocount': args.pseudocount}

# Preload deepBlue files, which need to then be deleted
deepBlueFiles = []
for idx, fname in enumerate([args.bigwig1, args.bigwig2]):
if db.isDeepBlue(fname):
deepBlueFiles.append([fname, idx])
if len(deepBlueFiles) > 0:
sys.stderr.write("Preloading the following deepBlue files: {}\n".format(",".join([x[0] for x in deepBlueFiles])))
foo = db.deepBlue(deepBlueFiles[0][0], url=args.deepBlueURL, userKey=args.userKey)
regs = db.makeChromTiles(foo)
for x in deepBlueFiles:
x.extend([args, regs])
if len(deepBlueFiles) > 1 and args.numberOfProcessors > 1:
pool = multiprocessing.Pool(args.numberOfProcessors)
res = pool.map_async(db.preloadWrapper, deepBlueFiles).get(9999999)
else:
res = list(map(db.preloadWrapper, deepBlueFiles))

# substitute the file names with the temp files
for (ftuple, r) in zip(deepBlueFiles, res):
if ftuple[1] == 0:
args.bigwig1 = r
else:
args.bigwig2 = r
deepBlueFiles = [[x[0], x[1]] for x in deepBlueFiles]
del regs

writeBedGraph_bam_and_bw.writeBedGraph(
[(args.bigwig1, getType(args.bigwig1)),
(args.bigwig2, getType(args.bigwig2))],
Expand All @@ -176,17 +148,3 @@ def main(args=None):
missingDataAsZero=not args.skipNonCoveredRegions,
extendPairedEnds=False,
fixedStep=args.fixedStep)

# Clean up temporary bigWig files, if applicable
if not args.deepBlueKeepTemp:
for k, v in deepBlueFiles:
if v == 0:
os.remove(args.bigwig1)
else:
os.remove(args.bigwig2)
else:
for k, v in deepBlueFiles:
foo = args.bigwig1
if v == 1:
foo = args.bigwig2
print("{} is stored in {}".format(k, foo))
40 changes: 4 additions & 36 deletions deeptools/computeMatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from deeptools import parserCommon
from deeptools import heatmapper
import deeptools.computeMatrixOperations as cmo
import deeptools.deepBlue as db
from importlib.metadata import version


Expand Down Expand Up @@ -44,17 +43,15 @@ def parse_arguments(args=None):
dest='command',
metavar='')

dbParser = parserCommon.deepBlueOptionalArgs()

# scale-regions mode options
subparsers.add_parser(
'scale-regions',
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
parents=[computeMatrixRequiredArgs(),
computeMatrixOutputArgs(),
computeMatrixOptArgs(case='scale-regions'),
parserCommon.gtf_options(),
dbParser],
parserCommon.gtf_options()
],
help="In the scale-regions mode, all regions in the BED file are "
"stretched or shrunken to the length (in bases) indicated by the user.",
usage='An example usage is:\n computeMatrix scale-regions -S '
Expand All @@ -67,8 +64,8 @@ def parse_arguments(args=None):
parents=[computeMatrixRequiredArgs(),
computeMatrixOutputArgs(),
computeMatrixOptArgs(case='reference-point'),
parserCommon.gtf_options(),
dbParser],
parserCommon.gtf_options()
],
help="Reference-point refers to a position within a BED region "
"(e.g., the starting point). In this mode, only those genomic"
"positions before (upstream) and/or after (downstream) of the "
Expand Down Expand Up @@ -399,28 +396,6 @@ def main(args=None):

hm = heatmapper.heatmapper()

# Preload deepBlue files, which need to then be deleted
deepBlueFiles = []
for idx, fname in enumerate(args.scoreFileName):
if db.isDeepBlue(fname):
deepBlueFiles.append([fname, idx])
if len(deepBlueFiles) > 0:
sys.stderr.write("Preloading the following deepBlue files: {}\n".format(",".join([x[0] for x in deepBlueFiles])))
regs = db.makeRegions(args.regionsFileName, args)
for x in deepBlueFiles:
x.extend([args, regs])
if len(deepBlueFiles) > 1 and args.numberOfProcessors > 1:
pool = multiprocessing.Pool(args.numberOfProcessors)
res = pool.map_async(db.preloadWrapper, deepBlueFiles).get(9999999)
else:
res = list(map(db.preloadWrapper, deepBlueFiles))

# substitute the file names with the temp files
for (ftuple, r) in zip(deepBlueFiles, res):
args.scoreFileName[ftuple[1]] = r
deepBlueFiles = [[x[0], x[1]] for x in deepBlueFiles]
del regs

scores_file_list = args.scoreFileName
hm.computeMatrix(scores_file_list, args.regionsFileName, parameters, blackListFileName=args.blackListFileName, verbose=args.verbose, allArgs=args)
if args.sortRegions not in ['no', 'keep']:
Expand All @@ -447,10 +422,3 @@ def main(args=None):
if args.outFileSortedRegions:
hm.save_BED(args.outFileSortedRegions)

# Clean up temporary bigWig files, if applicable
if not args.deepBlueKeepTemp:
for k, v in deepBlueFiles:
os.remove(args.scoreFileName[v])
else:
for k, v in deepBlueFiles:
print("{} is stored in {}".format(k, args.scoreFileName[v]))
Loading

0 comments on commit 80b646b

Please sign in to comment.