Skip to content

Commit 7cfaca2

Browse files
committed
fixed mergeBam
1 parent ffb97c0 commit 7cfaca2

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

halvade/src/be/ugent/intec/halvade/HalvadeOptions.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,10 @@ protected void createOptions() {
394394
.withDescription("Adds custom arguments for a tool. If a module in a tool is used, add the name after an underscore. "
395395
+ "Possible values: " + getProgramNames())
396396
.create("CA");
397+
Option optVerbose = OptionBuilder.withArgName("num")
398+
.hasArg()
399+
.withDescription("Sets verbosity of debugging [2].")
400+
.create("v");
397401
Option optAln = OptionBuilder.withArgName("num")
398402
.hasArg()
399403
.withDescription("Sets the aligner used in Halvade. Possible values are 0 (bwa aln+sampe)[default], 1 (bwa mem), 2 (bowtie2), 3 (cushaw2).")
@@ -474,6 +478,7 @@ protected void createOptions() {
474478
options.addOption(optRedis);
475479
options.addOption(optRmem);
476480
options.addOption(optMergeBam);
481+
options.addOption(optVerbose);
477482
}
478483

479484
protected boolean parseArguments(String[] args, Configuration halvadeConf) throws ParseException {
@@ -609,6 +614,9 @@ protected boolean parseArguments(String[] args, Configuration halvadeConf) throw
609614
if (line.hasOption("fbed")) {
610615
filterBed = line.getOptionValue("fbed");
611616
}
617+
if (line.hasOption("v")) {
618+
Logger.SETLEVEL(Integer.parseInt(line.getOptionValue("v")));
619+
}
612620

613621
if (line.hasOption("CA")) {
614622
Properties props = line.getOptionProperties("CA");

halvade/src/be/ugent/intec/halvade/MapReduceRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ protected int runHalvadeJob(Configuration halvadeConf, String tmpOutDir, int job
182182
halvadeJob.setReducerClass(be.ugent.intec.halvade.hadoop.mapreduce.RnaGATKReducer.class);
183183
} else if(jobType == HalvadeResourceManager.DNA){
184184
halvadeJob.setMapperClass(halvadeOpts.alignmentTools[halvadeOpts.aln]);
185-
halvadeJob.setReducerClass(be.ugent.intec.halvade.hadoop.mapreduce.DnaGATKReducer.class);
185+
halvadeJob.setReducerClass(be.ugent.intec.halvade.hadoop.mapreduce.DnaGATKReducer.class);
186186
}
187187

188188

halvade/src/be/ugent/intec/halvade/hadoop/mapreduce/BamMergeReducer.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
package be.ugent.intec.halvade.hadoop.mapreduce;
88

9+
import be.ugent.intec.halvade.hadoop.datatypes.ChromosomeRegion;
910
import be.ugent.intec.halvade.utils.HalvadeConf;
1011
import htsjdk.samtools.SAMFileHeader;
1112
import htsjdk.samtools.SAMReadGroupRecord;
@@ -25,19 +26,20 @@
2526
*
2627
* @author ddecap
2728
*/
28-
public class BamMergeReducer extends Reducer<LongWritable, SAMRecordWritable, LongWritable, SAMRecordWritable> {
29+
public class BamMergeReducer extends Reducer<ChromosomeRegion, SAMRecordWritable, LongWritable, SAMRecordWritable> {
2930

3031
protected SAMFileHeader header;
3132
protected SAMSequenceDictionary dict;
32-
KeyIgnoringBAMOutputFormat outpFormat;
33+
protected KeyIgnoringBAMOutputFormat outpFormat;
3334
protected String RGID = "GROUP1";
3435
protected String RGLB = "LIB1";
3536
protected String RGPL = "ILLUMINA";
3637
protected String RGPU = "UNIT1";
3738
protected String RGSM = "SAMPLE1";
3839
protected SAMReadGroupRecord bamrg;
3940
protected boolean inputIsBam = false;
40-
RecordWriter<LongWritable,SAMRecordWritable> recordWriter;
41+
protected RecordWriter<LongWritable,SAMRecordWritable> recordWriter;
42+
protected LongWritable outKey;
4143
boolean reportBest = false;
4244

4345
@Override
@@ -47,17 +49,18 @@ public void run(Context context) throws IOException, InterruptedException {
4749
}
4850

4951
@Override
50-
protected void reduce(LongWritable key, Iterable<SAMRecordWritable> values, Context context) throws IOException, InterruptedException {
52+
protected void reduce(ChromosomeRegion key, Iterable<SAMRecordWritable> values, Context context) throws IOException, InterruptedException {
5153
Iterator<SAMRecordWritable> it = values.iterator();
5254
while(it.hasNext())
53-
recordWriter.write(key, it.next());
55+
recordWriter.write(outKey, it.next());
5456
}
5557

5658
@Override
5759
protected void setup(Context context) throws IOException, InterruptedException {
5860
outpFormat = new KeyIgnoringBAMOutputFormat();
5961
String output = HalvadeConf.getOutDir(context.getConfiguration());
6062
inputIsBam = HalvadeConf.inputIsBam(context.getConfiguration());
63+
dict = HalvadeConf.getSequenceDictionary(context.getConfiguration());
6164
if(inputIsBam) {
6265
header = SAMHeaderReader.readSAMHeaderFrom(new Path(HalvadeConf.getHeaderFile(context.getConfiguration())), context.getConfiguration());
6366
} else {
@@ -74,6 +77,8 @@ protected void setup(Context context) throws IOException, InterruptedException {
7477

7578
outpFormat.setSAMHeader(header);
7679
recordWriter = outpFormat.getRecordWriter(context, new Path(output + "mergedBam.bam"));
80+
outKey = new LongWritable();
81+
outKey.set(0);
7782
}
7883

7984
protected void getReadGroupData(Configuration conf) {

halvade/src/be/ugent/intec/halvade/utils/ChromosomeSplitter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private void calculateRegionsPerChromosome(String bedFile) throws IOException {
255255
for (BedRegion breg : region.getValue()) {
256256
regionCount++;
257257
Logger.DEBUG("region: " + breg.key + ", " + contig +
258-
" (" + breg.start + " _ " + breg.end + " -> " + (breg.end - breg.start) + ")", 2);
258+
" (" + breg.start + " _ " + breg.end + " -> " + (breg.end - breg.start) + ")", 3);
259259
}
260260
}
261261
} finally {

0 commit comments

Comments
 (0)