Skip to content

Commit a840b34

Browse files
authored
Merge pull request #350 from AdamaJava/qsv_cram
fix(qsv): qsv can now write CRAM files internally
2 parents 7701e87 + 1da202d commit a840b34

File tree

19 files changed

+1840
-2094
lines changed

19 files changed

+1840
-2094
lines changed

q3tiledaligner/src/au/edu/qimr/tiledaligner/ReadTiledAligerFile.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626

2727
public class ReadTiledAligerFile {
2828

29-
private static TIntObjectMap<int[]> map = TCollections.synchronizedMap(new TIntObjectHashMap<>(1024 * 8));
29+
private static final TIntObjectMap<int[]> map = TCollections.synchronizedMap(new TIntObjectHashMap<>(1024 * 8));
3030

3131
public static void getTiledDataInMap(String tiledAlignerFile, int bufferSize) throws IOException {
3232
getTiledDataInMap(tiledAlignerFile, bufferSize, 1);
3333
}
3434

35-
public static void getTiledDataInMap(String tiledAlignerFile, int bufferSize, int threadPoolSize) throws IOException {
35+
public static void getTiledDataInMap(String tiledAlignerFile, int bufferSize, int threadPoolSize) {
3636

3737
AbstractQueue<String> queue = new LinkedBlockingQueue<>();
3838
AtomicBoolean hasReaderFinished = new AtomicBoolean(false);
@@ -68,7 +68,7 @@ public static void getTiledDataInMap(String tiledAlignerFile, int bufferSize, in
6868
}
6969

7070
static class Worker implements Runnable {
71-
private AbstractQueue<String> queue;
71+
private final AbstractQueue<String> queue;
7272
AtomicBoolean hasReaderFinished;
7373
public Worker(AbstractQueue<String> queue, AtomicBoolean hasReaderFinished) {
7474
this.queue = queue;
@@ -83,7 +83,7 @@ public void run() {
8383
e.printStackTrace();
8484
}
8585
System.out.println("Worker started...");
86-
String s = null;
86+
String s;
8787
int invalidCount = 0;
8888
while ( ! ((s = queue.poll()) == null && hasReaderFinished.get())) {
8989
if (null != s) {
@@ -104,11 +104,7 @@ public void run() {
104104
System.out.println("Worker has finished! invalidCount: " + invalidCount + ", map size: " + map.size());
105105
}
106106
}
107-
108-
public static TIntObjectMap<int[]> getCache(String tiledAlignerFile, int bufferSize) throws IOException {
109-
return getCache(tiledAlignerFile, bufferSize, 1);
110-
}
111-
107+
112108
public static TIntObjectMap<int[]> getCache(String tiledAlignerFile, int bufferSize, int threadCount) throws IOException {
113109
if (map.isEmpty()) {
114110
getTiledDataInMap(tiledAlignerFile, bufferSize, threadCount);

q3tiledaligner/src/au/edu/qimr/tiledaligner/util/TiledAlignerUtil.java

Lines changed: 94 additions & 108 deletions
Large diffs are not rendered by default.

qpicard/src/org/qcmg/picard/SAMFileReaderFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static SamReader createSAMFileReaderAsStream(final File bamFile, final Fi
7474
logger.info("setup index: " + index.getAbsolutePath());
7575
}
7676
//set reference file for cram. default reference set by java option "-Dsamjdk.REFERENCE_FASTA"
77-
if(reference != null && reference.exists()) {
77+
if (reference != null && reference.exists()) {
7878
factory.referenceSequence(reference);
7979
logger.info("setup reference: " + reference.getAbsolutePath());
8080
}

qsv/src/org/qcmg/qsv/Options.java

Lines changed: 21 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
*/
77
package org.qcmg.qsv;
88

9-
import static java.util.Arrays.asList;
10-
119
import java.io.File;
1210
import java.io.IOException;
11+
import java.nio.file.FileSystems;
1312
import java.nio.file.Files;
1413
import java.nio.file.Path;
1514
import java.nio.file.Paths;
@@ -36,12 +35,12 @@
3635
*
3736
*/
3837
public class Options {
39-
public static final String FILE_SEPERATOR = System.getProperty("file.separator");
38+
public static final String FILE_SEPARATOR = FileSystems.getDefault().getSeparator();
4039

4140
private static final String HELP_OPTION = Messages.getMessage("HELP_OPTION");
4241
private static final String VERSION_OPTION = Messages.getMessage("VERSION_OPTION");
4342
private static final String INI_OPTION = Messages.getMessage("INI_OPTION");
44-
private static final String TEMPDIR_OPTION = Messages.getMessage("TEMPDIR_OPTION");
43+
private static final String TEMP_DIR_OPTION = Messages.getMessage("TEMPDIR_OPTION");
4544
private static final String UUID_OPTION = Messages.getMessage("UUID_OPTION");;
4645

4746

@@ -53,7 +52,7 @@ public class Options {
5352
private String inputFile;
5453
private String outputDirName;
5554
private String outputDirNameOverride;
56-
private String uuid;
55+
private final String uuid;
5756
private String sampleName;
5857
private Integer filterSize;
5958
private Integer clusterSize;
@@ -93,19 +92,15 @@ public class Options {
9392

9493
/**
9594
* Takes arguments from the command line and sets up the options for qsv
96-
* @param args
97-
* @throws QSVException
98-
* @throws IOException
99-
* @throws InvalidFileFormatException
10095
*/
101-
public Options(final String[] args) throws QSVException, InvalidFileFormatException, IOException {
96+
public Options(final String[] args) throws QSVException, IOException {
10297

10398
//define the options the parse accepts
10499
parser.accepts("ini", INI_OPTION).withRequiredArg().ofType(String.class);
105-
parser.accepts("output-temporary", TEMPDIR_OPTION).withRequiredArg().ofType(String.class);
100+
parser.accepts("output-temporary", TEMP_DIR_OPTION).withRequiredArg().ofType(String.class);
106101
parser.accepts("uuid", UUID_OPTION).withOptionalArg().ofType(String.class);
107102
parser.accepts("help", HELP_OPTION);
108-
parser.acceptsAll(asList("version"), VERSION_OPTION);
103+
parser.acceptsAll(List.of("version"), VERSION_OPTION);
109104
options = parser.parse(args);
110105
//logging
111106

@@ -162,20 +157,20 @@ public void parseIniFile() throws QSVException, InvalidFileFormatException, IOEx
162157
if ( ! directoryExists(outputDirName)) {
163158
throw new QSVException("NO_OUTPUT_DIR", outputDirName);
164159
}
165-
outputDirName = (outputDirName.endsWith(FILE_SEPERATOR) ? outputDirName : outputDirName + FILE_SEPERATOR ) + uuid + FILE_SEPERATOR;
160+
outputDirName = (outputDirName.endsWith(FILE_SEPARATOR) ? outputDirName : outputDirName + FILE_SEPARATOR) + uuid + FILE_SEPARATOR;
166161
createResultsDirectory(outputDirName);
167162
} else {
168163
throw new QSVException("NO_OUTPUT");
169164
}
170165

171166
if (generalSection.get("min_insert_size") != null) {
172-
minInsertSize = new Integer(generalSection.get("min_insert_size"));
167+
minInsertSize = Integer.valueOf(generalSection.get("min_insert_size"));
173168
} else {
174169
minInsertSize = QSVConstants.DEFAULT_MIN_INSERT_SIZE;
175170
}
176171

177172
if (generalSection.get("repeat_cutoff") != null) {
178-
repeatCountCutoff = new Integer(generalSection.get("repeat_cutoff"));
173+
repeatCountCutoff = Integer.parseInt(generalSection.get("repeat_cutoff"));
179174
}
180175

181176
//ranges can be null, means all chromosome
@@ -256,10 +251,10 @@ public void parseIniFile() throws QSVException, InvalidFileFormatException, IOEx
256251
mapper = pairSection.get("mapper");
257252
query = pairSection.get("pair_query");
258253
if (pairSection.get("cluster_size") != null) {
259-
clusterSize = new Integer(pairSection.get("cluster_size"));
254+
clusterSize = Integer.valueOf(pairSection.get("cluster_size"));
260255
}
261256
if (pairSection.get("filter_size") != null) {
262-
filterSize = new Integer(pairSection.get("filter_size"));
257+
filterSize = Integer.valueOf(pairSection.get("filter_size"));
263258
}
264259
}
265260

@@ -290,7 +285,7 @@ public void parseIniFile() throws QSVException, InvalidFileFormatException, IOEx
290285
qPrimerThreshold = 3;
291286

292287

293-
//Clippping params
288+
//Clipping params
294289
Section clipSection = ini.get("clip");
295290
if (clipSection != null) {
296291
clipQuery = clipSection.get("clip_query");
@@ -350,19 +345,16 @@ public int getRepeatCountCutoff() {
350345
return repeatCountCutoff;
351346
}
352347

353-
// public void setREPEAT_COUNT_CUTOFF(int rEPEAT_COUNT_CUTOFF) {
354-
// REPEAT_COUNT_CUTOFF = rEPEAT_COUNT_CUTOFF;
355-
// }
356-
357348
private void processRanges() throws QSVException {
358349
includeTranslocations = false;
359350
allChromosomes = true;
360-
if (ranges != null && ranges.size() > 0) {
351+
if (ranges != null && ! ranges.isEmpty()) {
361352
allChromosomes = false;
362353
for (String s: ranges) {
363-
if (s.equals("inter")) {
364-
includeTranslocations = true;
365-
}
354+
if (s.equals("inter")) {
355+
includeTranslocations = true;
356+
break;
357+
}
366358
}
367359
if (ranges.size() > 1 && includeTranslocations) {
368360
throw new QSVException("RANGE_ERROR");
@@ -372,8 +364,7 @@ private void processRanges() throws QSVException {
372364

373365
/**
374366
* Detects any problems with the supplied options
375-
* @throws QSVException
376-
*/
367+
*/
377368
public void detectBadOptions() throws QSVException {
378369
if (log == null) {
379370
throw new QSVException("MISSING_LOG_FILE");
@@ -400,7 +391,7 @@ public void detectBadOptions() throws QSVException {
400391
throw new QSVException("NO_REFERENCE_FILE", reference);
401392
}
402393
} else {
403-
if (reference == null && isQCMG) {
394+
if (isQCMG) {
404395
throw new QSVException("NULL_REFERENCE_FILE");
405396
}
406397
}
@@ -409,7 +400,7 @@ public void detectBadOptions() throws QSVException {
409400
throw new QSVException("NO_REFERENCE_INDEX_FILE", referenceIndex);
410401
}
411402
} else {
412-
if (referenceIndex == null && isQCMG) {
403+
if (isQCMG) {
413404
throw new QSVException("NULL_REFERENCE_INDEX_FILE");
414405
}
415406
}
@@ -482,41 +473,24 @@ public boolean hasHelpOption() {
482473

483474
/**
484475
* Display help information
485-
* @throws Exception
486476
*/
487477
public void displayHelp() throws Exception {
488478
parser.formatHelpWith(new BuiltinHelpFormatter(150, 2));
489479
parser.printHelpOn(System.err);
490480
}
491481

492-
public void setRanges(List<String> ranges) {
493-
this.ranges = ranges;
494-
}
495-
496482
public List<String> getGffFiles() {
497483
return gffFiles;
498484
}
499485

500-
public void setGffFiles(List<String> gffFiles) {
501-
this.gffFiles = gffFiles;
502-
}
503-
504486
public Integer getMinInsertSize() {
505487
return minInsertSize;
506488
}
507489

508-
public void setMinInsertSize(Integer minInsertSize) {
509-
this.minInsertSize = minInsertSize;
510-
}
511-
512490
public boolean isSplitRead() {
513491
return isSplitRead;
514492
}
515493

516-
public void setSplitRead(boolean isSplitRead) {
517-
this.isSplitRead = isSplitRead;
518-
}
519-
520494
public String getPreprocessMode() {
521495
return preprocessMode;
522496
}
@@ -585,18 +559,10 @@ public Integer getClipSize() {
585559
return clipSize;
586560
}
587561

588-
public void setClipSize(Integer clipSize) {
589-
this.clipSize = clipSize;
590-
}
591-
592562
public Integer getConsensusLength() {
593563
return consensusLength;
594564
}
595565

596-
public void setConsensusLength(Integer consensusLength) {
597-
this.consensusLength = consensusLength;
598-
}
599-
600566
public String getMapper() {
601567
return mapper;
602568
}
@@ -613,10 +579,6 @@ public String getPlatform() {
613579
return platform;
614580
}
615581

616-
public void setPlatform(String platform) {
617-
this.platform = platform;
618-
}
619-
620582
public boolean directoryExists(String directoryName) {
621583
File file = new File(directoryName);
622584
return file.exists() && file.isDirectory();
@@ -681,19 +643,11 @@ public void setPairingType(String pairingType) {
681643
public boolean isSingleFileMode() {
682644
return singleFileMode;
683645
}
684-
685-
public void setSingleFileMode(boolean singleFileMode) {
686-
this.singleFileMode = singleFileMode;
687-
}
688646

689647
public boolean isTwoFileMode() {
690648
return twoFileMode;
691649
}
692650

693-
public void setTwoFileMode(boolean twoFileMode) {
694-
this.twoFileMode = twoFileMode;
695-
}
696-
697651
public boolean runClipAnalysis() {
698652
return (analysisMode.equals("both") || analysisMode.equals("clip")) ;
699653
}
@@ -717,10 +671,6 @@ public String getTiledAligner() {
717671
return tiledAlignerFile;
718672
}
719673

720-
public void setSequencingPlatform(String sequencingPlatform) {
721-
this.sequencingPlatform = sequencingPlatform;
722-
}
723-
724674
public String translateReference() {
725675
File ref = new File(reference);
726676
if (ref.exists()) {

0 commit comments

Comments
 (0)