diff --git a/CHANGES b/CHANGES index 546c190..46d1f44 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +## 0.8.0 (2019-09-04) +- Added CreateNetwork to tools +- Smaller bugfixes + ## 0.7.0 (2019-08-13) - Updated the way p-values are calculated in BINDetect. Included 100-fold subsampling of background to estimate confidence interval. diff --git a/tobias/__init__.py b/tobias/__init__.py index 49e0fc1..777f190 100644 --- a/tobias/__init__.py +++ b/tobias/__init__.py @@ -1 +1 @@ -__version__ = "0.7.0" +__version__ = "0.8.0" diff --git a/tobias/motifs/score_bed.py b/tobias/motifs/score_bed.py index cc1b7d5..58b7a63 100644 --- a/tobias/motifs/score_bed.py +++ b/tobias/motifs/score_bed.py @@ -47,7 +47,7 @@ def add_scorebed_arguments(parser): #Optional arguments optional = parser.add_argument_group('Optional arguments') - optional.add_argument('--output', metavar="", help="Path to output .bed-file (default: scored sites are written to stdout") + optional.add_argument('--output', metavar="", help="Path to output .bed-file (default: scored sites are written to stdout)") optional.add_argument('--subset', metavar="", help="Subset scoring to .bed regions and set all other sites to --null value (default: all sites in input file will be scored)") optional.add_argument('--null', metavar="", help="If --subset is given, which score/label to add to non-scored regions (default: 0)", default="0", type=float) optional.add_argument('--position', metavar="", help="Position in sites to score (start/mid/end/full) (default: full)", choices=["mid", "start", "end", "full"], default="full") @@ -132,6 +132,10 @@ def run_scorebed(args): pybw = {bigwig_f: pyBigWig.open(bigwig_f) for bigwig_f in args.bigwigs} #open filehandles for all bigwigs + #Get chrom/start/stop from pybw objects + pybw_headers = {bigwig_f: pybw[bigwig_f].chroms() for bigwig_f in pybw} + logger.debug(pybw_headers) + logger.info("Starting scoring...") #buff = [""]*args.buffer #buff_idx = 0 @@ -148,14 +152,22 @@ def run_scorebed(args): if overlap != 0: for bigwig_f in args.bigwigs: #preserves order of bigwigs - signal = pybw[bigwig_f].values(chrom, start, end, numpy=True) - - if len(signal) > 0: - signal = np.nan_to_num(signal) - score = round(score_func(signal), 5) + if chrom in pybw_headers[bigwig_f]: #only get score if chromosome is in bigwig; to prevent error from pybigwig.values + try: + signal = pybw[bigwig_f].values(chrom, start, end, numpy=True) + except: + logger.error("Error reading signal for site: {0}".format(line)) + sys.exit() + + if len(signal) > 0: + signal = np.nan_to_num(signal) + score = round(score_func(signal), 5) + else: + score = args.null else: score = args.null - + + #Format line with score outline += "\t" + "{0:.5f}".format(score) else: outline += "\t" + "\t".join([args.null]*no_bigwigs) diff --git a/tobias/plotting/plot_heatmap.py b/tobias/plotting/plot_heatmap.py index b9751ed..2da1209 100644 --- a/tobias/plotting/plot_heatmap.py +++ b/tobias/plotting/plot_heatmap.py @@ -139,7 +139,7 @@ def run_heatmap(args): #Estimate region width distri = heatmap_info[col][row]["regions"].get_width_distri() if len(distri) > 1: - sys.exit(distri) + logger.warning("Input regions have differing lengths: {0}".format(distri)) heatmap_info[col][row]["width"] = list(distri.keys())[0]