From a7cdb883e2dc69c14efe0260309b69d537db3e90 Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Tue, 1 Sep 2020 09:09:48 +0200 Subject: [PATCH 1/2] modify get_scores to reach end_region --- pygenometracks/tests/generateAllOutput.sh | 1 + pygenometracks/tests/test_bedGraphTrack.py | 28 ++++++++++++++++++ .../test_data/bedgraph_end_not_covered.ini | 7 +++++ .../master_bedgraph_end_not_covered.png | Bin 0 -> 10414 bytes pygenometracks/tests/test_data/simple.bdg | 6 ++++ pygenometracks/tracks/BedGraphTrack.py | 9 ++++-- 6 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 pygenometracks/tests/test_data/bedgraph_end_not_covered.ini create mode 100644 pygenometracks/tests/test_data/master_bedgraph_end_not_covered.png create mode 100644 pygenometracks/tests/test_data/simple.bdg diff --git a/pygenometracks/tests/generateAllOutput.sh b/pygenometracks/tests/generateAllOutput.sh index 92350ec5..deeb1fac 100644 --- a/pygenometracks/tests/generateAllOutput.sh +++ b/pygenometracks/tests/generateAllOutput.sh @@ -34,6 +34,7 @@ bin/pgt --tracks ./pygenometracks/tests/test_data/bedgraph_useMid.ini --region c bin/pgt --tracks ./pygenometracks/tests/test_data/operation_bdg.ini --region X:2700000-3100000 --trackLabelFraction 0.2 --dpi 130 -o ./pygenometracks/tests/test_data/master_operation_bdg.png bin/pgt --tracks ./pygenometracks/tests/test_data/bedgraph_withNA.ini --region X:2700000-3100000 --trackLabelFraction 0.2 --dpi 130 -o ./pygenometracks/tests/test_data/master_bedgraph_withNA.png bin/pgt --tracks ./pygenometracks/tests/test_data/bedgraph_negative.ini --region X:2700000-3100000 --trackLabelFraction 0.2 --dpi 130 -o ./pygenometracks/tests/test_data/master_negative.png +bin/pgt --tracks ./pygenometracks/tests/test_data/bedgraph_end_not_covered.ini --region chr7:100-400 --trackLabelFraction 0.2 --dpi 130 -o ./pygenometracks/tests/test_data/master_bedgraph_end_not_covered.png # test bigWigTrack: bin/pgt --tracks ./pygenometracks/tests/test_data/bigwig.ini --region X:2700000-3100000 --trackLabelFraction 0.2 --dpi 130 -o ./pygenometracks/tests/test_data/master_bigwig.png diff --git a/pygenometracks/tests/test_bedGraphTrack.py b/pygenometracks/tests/test_bedGraphTrack.py index 29c986c7..620d816a 100644 --- a/pygenometracks/tests/test_bedGraphTrack.py +++ b/pygenometracks/tests/test_bedGraphTrack.py @@ -214,6 +214,18 @@ with open(os.path.join(ROOT, "log1pm_bedgraph.ini"), 'w') as fh: fh.write(log1p_with_neg) + +bedgraph_end_not_covered = """ +[bedgraph] +file = simple.bdg +height = 3 +summary_method = max + +[x-axis] +""" +with open(os.path.join(ROOT, "bedgraph_end_not_covered.ini"), 'w') as fh: + fh.write(bedgraph_end_not_covered) + tolerance = 13 # default matplotlib pixed difference tolerance @@ -419,3 +431,19 @@ def test_bedgraph_neg_log1p(): os.remove(ini_file) os.remove(os.path.join(ROOT, "bedgraph_chrx_2e6_5e6_m.bg")) + + +def test_bedgraph_end_not_covered(): + region = "chr7:100-400" + outfile = NamedTemporaryFile(suffix='.png', prefix='bedgraph_end_not_covered_', delete=False) + args = "--tracks {ini} --region {region} --trackLabelFraction 0.2 " \ + "--dpi 130 --outFileName {outfile}" \ + "".format(ini=os.path.join(ROOT, "bedgraph_end_not_covered.ini"), + outfile=outfile.name, region=region).split() + pygenometracks.plotTracks.main(args) + print("saving test to {}".format(outfile.name)) + res = compare_images(os.path.join(ROOT, 'master_bedgraph_end_not_covered.png'), + outfile.name, tolerance) + assert res is None, res + + os.remove(outfile.name) diff --git a/pygenometracks/tests/test_data/bedgraph_end_not_covered.ini b/pygenometracks/tests/test_data/bedgraph_end_not_covered.ini new file mode 100644 index 00000000..fbaa6f10 --- /dev/null +++ b/pygenometracks/tests/test_data/bedgraph_end_not_covered.ini @@ -0,0 +1,7 @@ + +[bedgraph] +file = simple.bdg +height = 3 +summary_method = max + +[x-axis] diff --git a/pygenometracks/tests/test_data/master_bedgraph_end_not_covered.png b/pygenometracks/tests/test_data/master_bedgraph_end_not_covered.png new file mode 100644 index 0000000000000000000000000000000000000000..81facbd75e446b78dc8b96ae891da9be55d5c833 GIT binary patch literal 10414 zcmd^l2~?Bk)^4n)QnhOPI~`sFR3@2aHcX+lN(%}a5JZOH z1Tscs9zq4|gBs;xR>f>7srrczH)5`nZ3QH0n--eSmi&lSpYgn^ZymDb0`&U@H<=1ham&BE~ zd&`)n^Y|^s8+C@#PJMR=zVwzRU!~}XJDkb%n_9hhW6gB-1&W)5@4w-ym^~?cRwKSmOJVBjn=#Rnn4hWU3i}!1>LVOb#pXO40D)PbJ zEb8y$=SnYMnC*0{MSP7qLoc@39IJ2t=7tMF znCP5ZGgU1|?((APOGsZf9Isj&S03~JO48xM+}bNZ$**`X#W;>5|1a#1a{{)Yy7#4{P=gQS#ef&UM+E{n#iuhi+mCe z38Js?l32+eB|VxoigN#0S(EUpM=gEg2gXr84cdbaV&NP^(mA=wjY;4nIzRInsFkk? z=<;B?F<15~Jnu>F?3(g^d%4B4Z8=u4*_0|B4Grp?_I09=Nu<}Q(2`54W^yIfosLm# zmsct)b8lphi)-GjX1M%nSGSXyr?RLUFlj#?krFZPX(-ZQnbl!gM)Rv>sR1d$6I3m{ zaKzFg^OVo<Bdt&bA*koM&HcXzg8di#_DMOYJGk3EpFl?|fW2Ml>=q67|W6 zz6~DDH)+tFsI;qSczJETZ@p?Y`*DKZa!}x6_snz_t;{(s`-p%pZZ^|Z%C@95sDw>L z@h4a`%e;KQ;djzOL-(!9{anoSXIet0qVS`4xGPr~2HsIyBC9)_t=S}-%m^L#mC8}F zE&lg&wR%n*j|N2qyrmzuSDxVzV1h>(dd^Bv^qPY}#K%ZJlj+Ty3lE8!om zbxW(;vU8I*`_>H^T}`ZT*c?BzuwJF|)~iieJsKo{It*fopMj-wlDzC5+kW=(nTFNW zzN$9Se1A+vRh0q5U~x3t4l7>b@hVtCWt^IO`_tsGh2h*(;z(u&=lSYQqcfqOt~82z&aD&Guw-}!oGp+pk#y?ee;@&kj9v?_Se>3FT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#4ceA>@ElIi)KzSQ&{sh<*m>l!PSD@_ky}myM9G zg?b&JB|E|v$JBucguGuZ_qNo#Ka1KbUsJ@i>zWSfEOa^Dy%r6FpL68I7ULr5;Cy`f n*_sw Date: Tue, 1 Sep 2020 09:24:22 +0200 Subject: [PATCH 2/2] linting --- pygenometracks/tracks/BedGraphTrack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygenometracks/tracks/BedGraphTrack.py b/pygenometracks/tracks/BedGraphTrack.py index 857cf8c0..ceab40ac 100644 --- a/pygenometracks/tracks/BedGraphTrack.py +++ b/pygenometracks/tracks/BedGraphTrack.py @@ -293,7 +293,7 @@ def get_scores(self, chrom_region, start_region, end_region, prev_end = end score_list.append(values) pos_list.append((start, end)) - + # Add a last value if needed: if prev_end < end_region and return_nans: score_list.append(np.repeat(np.nan, self.num_fields))