Skip to content

Commit a3fb1e1

Browse files
authored
Merge pull request #386 from AdamaJava/qcoverage_fix
Qcoverage fix
2 parents b34af16 + 17039ed commit a3fb1e1

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed

qcoverage/src/org/qcmg/coverage/Coverage.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,9 @@ private void saveCoverageReport(CoverageType coverageType) throws Exception {
204204
if (coverageType.equals(CoverageType.LOW_READDEPTH)) {
205205

206206
String outfile = options.getOutputFileNames()[0];
207-
//rename .bed extension if present to add the mnin coverage value
208-
if (outfile.endsWith(".bed")) {
209-
outfile = outfile.substring(0, outfile.length() - 4);
207+
if (!outfile.endsWith(".bed")) {
208+
outfile = outfile + ".bed";
210209
}
211-
outfile = String.format("%s.low_read_depth.%s.bed", outfile, options.getLowReadDepthCutoff());
212210

213211
final HashMap<String, List<LowReadDepthRegion>> lowReadDepthResultsFinalMap = jobQueue.getLowReadDepthResultsFinalMap();
214212
LinkedHashSet<String> refNamesOrdered = jobQueue.getRefNamesOrdered();

qcoverage/test/org/qcmg/coverage/CoverageTest.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class CoverageTest {
3434
public TemporaryFolder testFolder = new TemporaryFolder();
3535

3636

37-
@Before
37+
@Before
3838
public void setup() throws IOException {
3939
inputBam = testFolder.newFile("coverage.bam").getAbsolutePath();
4040
inputBai = inputBam.replace("bam", "bai");
@@ -59,8 +59,8 @@ public void setup() throws IOException {
5959
fname = testFolder.getRoot().getAbsolutePath()+"/output.txt";
6060
bedname = testFolder.getRoot().getAbsolutePath()+"/output.bed";
6161

62-
}
63-
62+
}
63+
6464
@Test
6565
public final void defaultTest() throws Exception {
6666

@@ -105,17 +105,25 @@ public final void testLowReadDepthOption() throws Exception {
105105
Executor exec = execute(cmd);
106106
assertEquals(0, exec.getErrCode());
107107
File fBedOutput = new File(bedname);
108-
assertFalse(fBedOutput.exists());
108+
assertTrue(fBedOutput.exists());
109+
}
109110

110-
//filename should have file endings .low_read_depth.[readdepth-cutoff value].bed
111-
File outputBed = new File(bedname.replace(".bed",".low_read_depth.8.bed"));
112-
assertTrue(outputBed.exists());
111+
@Test
112+
public final void testLowReadDepthOptionNoBedExtension() throws Exception {
113+
String bed = bedname.replace(".bed","");
114+
String cmd = "--log " + log + " --type low_readdepth --input-gff3 " + inputGff3 + " --input-bam " + inputBam +
115+
" --input-bai " + inputBai + " --output " + bed + " --output-format bed --readdepth-cutoff 8";
113116

114-
//filename should have file endings .low_read_depth.[readdepth-cutoff value].bed
115-
outputBed = new File(bedname.replace(".bed",".low_read_depth.12.bed"));
116-
assertFalse(outputBed.exists());
117+
//default value txt output only
118+
Executor exec = execute(cmd);
119+
assertEquals(0, exec.getErrCode());
120+
File fBedOutput = new File(bed);
121+
assertFalse(fBedOutput.exists());
122+
123+
fBedOutput = new File(bedname);
124+
assertTrue(fBedOutput.exists());
125+
}
117126

118-
}
119127

120128
@Test
121129
public final void testLowReadDepthOptionMissingCutoffOption() throws Exception {

qcoverage/test/org/qcmg/coverage/LowReadDepthTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ private Executor execute(final String command) throws Exception {
6666

6767
@Test
6868
public void lowReadDepthMinEight() throws Exception {
69-
String fname = testFolder.getRoot().getAbsolutePath() + "/output";
70-
File fOutput = new File(fname + ".low_read_depth.8.bed");
69+
String fname = testFolder.getRoot().getAbsolutePath() + "/output.bed";
70+
File fOutput = new File(fname);
7171
String cmd = "--log ./logfile --type low_readdepth --input-gff3 " + gff1000To1065 + " --input-bam " + bam + " --input-bai " + bai + " --output " + fname + " --readdepth-cutoff 8";
7272

7373
Executor exec = execute(cmd);
@@ -91,8 +91,8 @@ public void lowReadDepthMinEight() throws Exception {
9191

9292
@Test
9393
public void lowReadDepthMinTwelve() throws Exception {
94-
String fname = testFolder.getRoot().getAbsolutePath() + "/output";
95-
File fOutput = new File(fname + ".low_read_depth.12.bed");
94+
String fname = testFolder.getRoot().getAbsolutePath() + "/output.bed";
95+
File fOutput = new File(fname);
9696
String cmd = "--log ./logfile --type low_readdepth --input-gff3 " + gff1000To1065 + " --input-bam " + bam + " --input-bai " + bai + " --output " + fname + " --readdepth-cutoff 12";
9797

9898
Executor exec = execute(cmd);

qcoverage/test/org/qcmg/coverage/QueryLowReadDepthTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ private Executor execute(final String command) throws Exception {
6666

6767
@Test
6868
public void lowReadDepthMinTwelveQuery() throws Exception {
69-
String fname = testFolder.getRoot().getAbsolutePath() + "/output";
70-
File fOutput = new File(fname + ".low_read_depth.12.bed");
69+
String fname = testFolder.getRoot().getAbsolutePath() + "/output.bed";
70+
File fOutput = new File(fname);
7171
String cmd = "--log ./logfile --type low_readdepth --input-gff3 " + gff1000To1065 + " --input-bam " + bam + " --input-bai " + bai + " --output " + fname + " --readdepth-cutoff 12 --query and(flag_DuplicateRead==false,flag_NotprimaryAlignment==false,MAPQ>10)";
7272

7373
Executor exec = execute(cmd);
@@ -89,8 +89,8 @@ public void lowReadDepthMinTwelveQuery() throws Exception {
8989

9090
@Test
9191
public void lowReadDepthMinEightQuery() throws Exception {
92-
String fname = testFolder.getRoot().getAbsolutePath() + "/output";
93-
File fOutput = new File(fname + ".low_read_depth.8.bed");
92+
String fname = testFolder.getRoot().getAbsolutePath() + "/output.bed";
93+
File fOutput = new File(fname);
9494
String cmd = "--log ./logfile --type low_readdepth --input-gff3 " + gff1000To1065 + " --input-bam " + bam + " --input-bai " + bai + " --output " + fname + " --readdepth-cutoff 8 --query and(flag_DuplicateRead==false,flag_NotprimaryAlignment==false,MAPQ>10)";
9595

9696
Executor exec = execute(cmd);

0 commit comments

Comments
 (0)