diff --git a/qbasepileup/build.gradle b/qbasepileup/build.gradle index b3b5136dc..0aec9baf4 100644 --- a/qbasepileup/build.gradle +++ b/qbasepileup/build.gradle @@ -4,22 +4,19 @@ mainClassName = 'org.qcmg.qbasepileup.QBasePileup' def scriptname = 'qbasepileup' def isExecutable = true -repositories { - flatDir(dirs:"$buildDir/deps/hdf-java/lib") -} - //control the ordering of jars, make sure junit before .jar configurations { junit } +repositories { + flatDir(dirs:["$buildDir/deps/hdf-java/lib", "/opt/local/genomeinfo/hdf-java/hdf-java-2.8/lib"]) +} dependencies { - ant { untar(src: "../lib/hdf-java-2.8-bin.tar", dest: "build/deps") } - implementation name: 'jhdf' - implementation name: 'jhdf5' - implementation name: 'jhdfobj' - implementation name: 'jhdf5obj' + + ant { untar(src: "../lib/hdf-java-2.8-bin.tar", dest: "build/deps") } + implementation project(':qcommon') - implementation project(':qpileup') implementation project(':qbamfilter') + implementation project(':qpileup') implementation 'com.github.samtools:htsjdk:2.24.1' implementation 'net.sf.jopt-simple:jopt-simple:4.6' testImplementation 'org.easymock:easymock:5.2.0' diff --git a/qbasepileup/src/org/qcmg/qbasepileup/InputBAM.java b/qbasepileup/src/org/qcmg/qbasepileup/InputBAM.java index c991eb0c1..8e7642a64 100644 --- a/qbasepileup/src/org/qcmg/qbasepileup/InputBAM.java +++ b/qbasepileup/src/org/qcmg/qbasepileup/InputBAM.java @@ -35,34 +35,25 @@ public InputBAM(Integer id, String donor, File bamFile, String inputType) { public Integer getId() { return id; } - public String getDonor() { - return donor; - } + public File getBamFile() { return bamFile; } public boolean exists() { return this.bamFile.exists(); } - public String getInputType() { - return inputType; - } - + public SamReader getSAMFileReader() throws IOException { return SAMFileReaderFactory.createSAMFileReader(bamFile, null, ValidationStringency.SILENT); } @Override public String toString() { - if (inputType.equals(Options.INPUT_BAM)) { - return "\t\t" + this.bamFile.getAbsolutePath(); - } else if (inputType.equals(Options.INPUT_LIST)){ - return this.id + "\t" + this.donor + "\t" + this.bamFile.getAbsolutePath(); - } else if (inputType.equals(Options.INPUT_HDF)){ - return "\t\t" + this.bamFile.getAbsolutePath(); - } else { - return new String(); - } + return switch (inputType) { + case Options.INPUT_BAM, Options.INPUT_HDF -> "\t\t" + this.bamFile.getAbsolutePath(); + case Options.INPUT_LIST -> this.id + "\t" + this.donor + "\t" + this.bamFile.getAbsolutePath(); + default -> ""; + }; } diff --git a/qbasepileup/src/org/qcmg/qbasepileup/Messages.java b/qbasepileup/src/org/qcmg/qbasepileup/Messages.java index d6b13f4e9..8a4ff318c 100644 --- a/qbasepileup/src/org/qcmg/qbasepileup/Messages.java +++ b/qbasepileup/src/org/qcmg/qbasepileup/Messages.java @@ -11,7 +11,6 @@ public final class Messages { static final ResourceBundle messages = ResourceBundle.getBundle("org.qcmg.qbasepileup.messages"); - static final String ERROR_PREFIX = getProgramName() + ": "; static final String USAGE = getMessage("USAGE"); public static String getMessage(final String identifier) { @@ -38,7 +37,7 @@ static String getProgramVersion() { return Messages.class.getPackage().getImplementationVersion(); } - public static String getVersionMessage() throws Exception { + public static String getVersionMessage() { return getProgramName() + ", version " + getProgramVersion(); } } diff --git a/qbasepileup/src/org/qcmg/qbasepileup/Options.java b/qbasepileup/src/org/qcmg/qbasepileup/Options.java index 99dc281c5..18a51436f 100644 --- a/qbasepileup/src/org/qcmg/qbasepileup/Options.java +++ b/qbasepileup/src/org/qcmg/qbasepileup/Options.java @@ -45,7 +45,7 @@ public class Options { private boolean intron = true; private boolean indel = true; private int threadNo = 1; - private final List inputBAMs = new ArrayList(); + private final List inputBAMs = new ArrayList<>(); private File hdf; private String inputType; private int nearbyIndelWindow = 3; @@ -61,7 +61,6 @@ public class Options { private String filterQuery; //private Integer minCoverage; private Integer maxCoverage; - private Map pindelMutations; private Integer outputFormat = 1; public Options(final String[] args) throws Exception { @@ -120,10 +119,6 @@ public Options(final String[] args) throws Exception { log = (String) options.valueOf("log"); String loglevel = (String) options.valueOf("loglevel"); - if (loglevel == null) { - loglevel = "INFO"; - } - if (options.has("r")) { reference = new File((String) options.valueOf("r")); } @@ -225,30 +220,35 @@ public Options(final String[] args) throws Exception { //set filtering options - if (profile.equals("torrent")) { - baseQuality = 0; - mappingQuality = 1; - indel = true; - intron = true; - novelstarts = false; - strand=false; - } else if (profile.equals("RNA")) { - baseQuality = 7; - mappingQuality = 10; - indel = true; - intron = true; - novelstarts = true; - strand=false; - } else if (profile.equals("DNA")) { - baseQuality = 10; - mappingQuality = 10; - indel = true; - intron = false; - novelstarts = false; - strand=false; - } else if (profile.equals("indel")) { - - } + switch (profile) { + case "torrent": + baseQuality = 0; + mappingQuality = 1; + indel = true; + intron = true; + novelstarts = false; + strand = false; + break; + case "RNA": + baseQuality = 7; + mappingQuality = 10; + indel = true; + intron = true; + novelstarts = true; + strand = false; + break; + case "DNA": + baseQuality = 10; + mappingQuality = 10; + indel = true; + intron = false; + novelstarts = false; + strand = false; + break; + case "indel": + + break; + } if (options.has("bq")) { baseQuality = (Integer) options.valueOf("bq"); @@ -337,7 +337,7 @@ public Options(final String[] args) throws Exception { normalBam = new InputBAM(null, null, new File((String) options.valueOf("in")), inputType); if (options.has("pd") || options.has("pi")) { - this.pindelMutations = getPindelMutations(options); + Map pindelMutations = getPindelMutations(options); } } @@ -385,12 +385,8 @@ public Integer getOutputFormat() { return outputFormat; } - public Map getPindelMutations() { - return pindelMutations; - } - private Map getPindelMutations(OptionSet options) throws IOException { - Map pindelMutations = new HashMap(); + Map pindelMutations = new HashMap<>(); if (options.has("pd")) { File file = new File((String)options.valueOf("pd")); @@ -405,7 +401,7 @@ private Map getPindelMutations(OptionSet options) throws IOExc private void readPindelMutationFile(Map pindelMutations, File file, String type) throws IOException { - try (BufferedReader reader = new BufferedReader(new FileReader(file));) { + try (BufferedReader reader = new BufferedReader(new FileReader(file))) { String line; List lines = new ArrayList<>(); while ((line = reader.readLine()) != null) { @@ -413,30 +409,30 @@ private void readPindelMutationFile(Map pindelMutations, if (lines.size() > 0) { String[] infos = lines.get(0).split("\t"); String chr = infos[3].replace("ChrID ", ""); - Integer start = new Integer(infos[4].replace("BP ", "")); - Integer end = new Integer(infos[5].replace("BP ", "")); + int start = Integer.parseInt(infos[4].replace("BP ", "")); + int end = Integer.parseInt(infos[5].replace("BP ", "")); if ("DEL".equals(type)) { start++; end--; } String key = chr + ":" + start + ":" + end + ":" + type; - String normal = ""; - String tumour = ""; + StringBuilder normal = new StringBuilder(); + StringBuilder tumour = new StringBuilder(); int normalCount = 0; int tumourCount = 0; for (int i=2; i 50000) { - IndelBasePileupByChrMT mtGerm = new IndelBasePileupByChrMT(options.getGermlineIndelFile(), options.getGermlineOutputFile(), options.getOutput(), true, options); + IndelBasePileupByChrMT mtGerm = new IndelBasePileupByChrMT(options.getGermlineIndelFile(), options.getGermlineOutputFile(), true, options); if (mtGerm.getExitStatus() > 0) { return 1; } diff --git a/qbasepileup/src/org/qcmg/qbasepileup/QBasePileupUtil.java b/qbasepileup/src/org/qcmg/qbasepileup/QBasePileupUtil.java index cb6926bdd..75fa33ccf 100644 --- a/qbasepileup/src/org/qcmg/qbasepileup/QBasePileupUtil.java +++ b/qbasepileup/src/org/qcmg/qbasepileup/QBasePileupUtil.java @@ -27,7 +27,7 @@ public class QBasePileupUtil { public static final char TAB = '\t'; - public static String getStrackTrace(Exception e) { + public static String getStackTrace(Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); @@ -68,10 +68,8 @@ public static boolean addChromosomeReference(String ref) { } Matcher matcher = DOUBLE_DIGIT_PATTERN.matcher(ref); - if (matcher.matches()) { - if (Integer.parseInt(ref) < 23) { - return true; - } + if (matcher.matches()) { + return Integer.parseInt(ref) < 23; } return false; } @@ -82,10 +80,9 @@ public static FastaSequenceIndex getFastaIndex(File reference) { } public static IndexedFastaSequenceFile getIndexedFastaFile(File reference) { - FastaSequenceIndex index = getFastaIndex(reference); - IndexedFastaSequenceFile indexedFasta = new IndexedFastaSequenceFile(reference, index); - - return indexedFasta; + FastaSequenceIndex index = getFastaIndex(reference); + + return new IndexedFastaSequenceFile(reference, index); } public static String printStackTrace(Exception e) { @@ -106,16 +103,16 @@ public static int[] parseDCCHeader(List headers) throws QBasePileupExcep if (values[i].toLowerCase().contains("qcmgflag")) { cols[0] = i; } - if (values[i].toLowerCase().equals("nd")) { + if (values[i].equalsIgnoreCase("nd")) { cols[1] = i; } - if (values[i].toLowerCase().equals("td")) { + if (values[i].equalsIgnoreCase("td")) { cols[2] = i; } - if (values[i].toLowerCase().equals("reference_genome_allele")) { + if (values[i].equalsIgnoreCase("reference_genome_allele")) { cols[3] = i; } - if (values[i].toLowerCase().equals("tumour_genotype")) { + if (values[i].equalsIgnoreCase("tumour_genotype")) { cols[4] = i; } } @@ -160,33 +157,22 @@ public static String getSequenceString(byte[] sequence) { * @return */ public static String[] getSNPPositionColumns(String format, String[] values, long count) { - - if (format.equals("dcc1") || format.equals("maf")) { - String[] columns = {values[2], values[4], values[5], values[6]}; - return columns; - } else if (format.equals("dccq")) { - String[] columns = {values[0], values[2], values[3], values[4]}; - return columns; - } else if (format.equals("vcf")) { - String[] columns = {values[2], values[0], values[1], values[1]}; - return columns; - } else if (format.equals("tab") || format.equals("columns")) { - String[] columns = {values[0], values[1], values[2], values[3]}; - return columns; - } else if (format.equals("hdf")) { - String[] columns = {Long.toString(count), values[0], values[1], values[2]}; - return columns; - } - - - - return null; + + return switch (format) { + case "dcc1", "maf" -> new String[]{values[2], values[4], values[5], values[6]}; + case "dccq" -> new String[]{values[0], values[2], values[3], values[4]}; + case "vcf" -> new String[]{values[2], values[0], values[1], values[1]}; + case "tab", "columns" -> new String[]{values[0], values[1], values[2], values[3]}; + case "hdf" -> new String[]{Long.toString(count), values[0], values[1], values[2]}; + default -> null; + }; + + } public static byte[] getCompoundAltBases(String[] values, int index) throws QBasePileupException { try { - byte[] bases = values[index].split(">")[1].getBytes(); - return bases; + return values[index].split(">")[1].getBytes(); } catch (Exception e) { throw new QBasePileupException("NO_MUTATION"); } @@ -246,7 +232,7 @@ public static List getHeaderLines(File file) throws IOException { public static List getHeaderLines(File file, boolean includeMutation) throws IOException { List headers = new ArrayList<>(); - try (BufferedReader reader = new BufferedReader(new FileReader(file));) { + try (BufferedReader reader = new BufferedReader(new FileReader(file))) { String line; while ((line=reader.readLine()) != null) { if (line.startsWith("Hugo") || line.startsWith("#") || line.startsWith("analysis_id") || (includeMutation && line.startsWith("mutation"))) { @@ -264,13 +250,11 @@ public static String getColumnsSnpHeader(List inputBAMs) { sb.append(TAAAAAB); sb.append(TAB); for (InputBAM input : inputBAMs) { - sb.append(input.getAbbreviatedBamFileName() + TAAAAAB); + sb.append(input.getAbbreviatedBamFileName()).append(TAAAAAB); } sb.append("\n"); sb.append("#gene\tchromosome\tstart\tend\tref\talt\t"); - for (int i=0; i readQueue = new ConcurrentLinkedQueue<>(); - final AbstractQueue writeQueue = new ConcurrentLinkedQueue(); + final AbstractQueue writeQueue = new ConcurrentLinkedQueue<>(); final CountDownLatch readLatch = new CountDownLatch(1); // reading // thread @@ -114,7 +114,7 @@ private void execute() throws Exception { logger.info("All threads finished"); } catch (Exception e) { - logger.info(QBasePileupUtil.getStrackTrace(e)); + logger.info(QBasePileupUtil.getStackTrace(e)); exitStatus.incrementAndGet(); } finally { // kill off any remaining threads @@ -123,14 +123,14 @@ private void execute() throws Exception { pileupThreads.shutdownNow(); } - logger.debug("TOTAL POSITIONS: \t\t\t" + positionCount); - logger.debug("UNIQUE POSITIONS: \t\t\t" + uniquePositionCount); - logger.debug("TOTAL READS EXAMINED:\t\t"+totalExamined+""); + logger.debug("TOTAL POSITIONS: \t\t\t" + positionCount); + logger.debug("UNIQUE POSITIONS: \t\t\t" + uniquePositionCount); + logger.debug("TOTAL READS EXAMINED:\t\t" + totalExamined); logger.debug("---------------------------------------------"); - logger.debug("TOTAL READS KEPT:\t\t"+totalPassedFilters); - logger.debug("TOTAL READS NOT ON SNP:\t\t"+totalReadsNotMapped); - logger.debug("READS WITH BAD BASE QUALITY:\t"+totalReadsBadBaseQual); - logger.debug("READS WITH BAD MAPPING QUALITY:\t"+totalReadsBaseMapQual); + logger.debug("TOTAL READS KEPT:\t\t" + totalPassedFilters); + logger.debug("TOTAL READS NOT ON SNP:\t\t" + totalReadsNotMapped); + logger.debug("READS WITH BAD BASE QUALITY:\t" + totalReadsBadBaseQual); + logger.debug("READS WITH BAD MAPPING QUALITY:\t" + totalReadsBaseMapQual); } private class Reading implements Runnable { @@ -151,7 +151,7 @@ public Reading(AbstractQueue q, Thread mainThread, this.pileupLatch = filterLatch; this.positionsFile = positionsFile; this.format = format; - this.positions = new ArrayList(); + this.positions = new ArrayList<>(); } @Override @@ -167,21 +167,20 @@ public void run() { count++; positionCount.incrementAndGet(); ChrRangePosition p = null; - String[] values = line.split("\t"); - - if (format.equals("dcc1")) { - p = new ChrRangePosition(values[4], Integer.parseInt(values[5]),Integer.parseInt(values[6])); - } else if (format.equals("dccq")) { - p = new ChrRangePosition(values[2],Integer.parseInt(values[3]),Integer.parseInt(values[4])); - } else if (format.equals("vcf")) { - p = new ChrRangePosition(values[0],Integer.parseInt(values[1]),Integer.parseInt(values[1])); - } else if (format.equals("maf")){ - p = new ChrRangePosition(values[4],Integer.parseInt(values[5]),Integer.parseInt(values[6])); - } else if (format.equals("tab")) { - p = new ChrRangePosition(values[1],Integer.parseInt(values[2]),Integer.parseInt(values[3])); - } else if (format.equals("gff3") || format.equals("gtf")) { - p = new ChrRangePosition(values[0],Integer.parseInt(values[3]),Integer.parseInt(values[4])); - } + String[] values = line.split("\t"); + + switch (format) { + case "dcc1", "maf" -> + p = new ChrRangePosition(values[4], Integer.parseInt(values[5]), Integer.parseInt(values[6])); + case "dccq" -> + p = new ChrRangePosition(values[2], Integer.parseInt(values[3]), Integer.parseInt(values[4])); + case "vcf" -> + p = new ChrRangePosition(values[0], Integer.parseInt(values[1]), Integer.parseInt(values[1])); + case "tab" -> + p = new ChrRangePosition(values[1], Integer.parseInt(values[2]), Integer.parseInt(values[3])); + case "gff3", "gtf" -> + p = new ChrRangePosition(values[0], Integer.parseInt(values[3]), Integer.parseInt(values[4])); + } if (!positions.contains(p)) { uniquePositionCount.incrementAndGet(); @@ -204,7 +203,7 @@ public void run() { countSleep++; } catch (Exception e) { logger.info(Thread.currentThread().getName() - + " " + QBasePileupUtil.getStrackTrace(e)); + + " " + QBasePileupUtil.getStackTrace(e)); } } } @@ -214,7 +213,7 @@ public void run() { logger.info("Completed reading thread, read " + count + " records from input: " + positionsFile.getAbsolutePath()); } catch (Exception e) { - logger.error("Setting exit status in execute thread to 1 as exception caught in reading method: " + QBasePileupUtil.getStrackTrace(e)); + logger.error("Setting exit status in execute thread to 1 as exception caught in reading method: " + QBasePileupUtil.getStackTrace(e)); if (exitStatus.intValue() == 0) { exitStatus.incrementAndGet(); } @@ -223,7 +222,7 @@ public void run() { readLatch.countDown(); logger.debug(String .format("Exit Reading thread, total slept %d times * %d milli-seconds, " - + "since input queue are full.fLatch is %d; queus size is %d ", + + "since input queue are full.fLatch is %d; queues size is %d ", countSleep, sleepUnit, pileupLatch.getCount(), queue.size())); } @@ -239,15 +238,14 @@ private class Pileup implements Runnable { private final CountDownLatch readLatch; private final CountDownLatch pileupLatch; private final CountDownLatch writeLatch; - private int countOutputSleep; - private final List currentInputs; + private final List currentInputs; private String file = null; private QueryExecutor exec = null; public Pileup(AbstractQueue queueIn, AbstractQueue queueOut, Thread mainThread, CountDownLatch readLatch, CountDownLatch pileupLatch, - CountDownLatch wGoodLatch, List inputs) throws Exception { + CountDownLatch wGoodLatch, List inputs) { this.queueIn = queueIn; this.queueOut = queueOut; this.mainThread = mainThread; @@ -255,9 +253,7 @@ public Pileup(AbstractQueue queueIn, this.pileupLatch = pileupLatch; this.writeLatch = wGoodLatch; this.currentInputs = new ArrayList<>(); - for (InputBAM i : inputs) { - currentInputs.add(i); - } + currentInputs.addAll(inputs); } @Override @@ -265,7 +261,7 @@ public void run() { int sleepcount = 0; int count = 0; - countOutputSleep = 0; + int countOutputSleep = 0; boolean run = true; try { @@ -286,8 +282,7 @@ public void run() { Thread.sleep(sleepUnit); sleepcount++; } catch (InterruptedException e) { - logger.info(Thread.currentThread().getName() + " " - + e.toString()); + logger.info(Thread.currentThread().getName() + " " + e); } } else { @@ -303,7 +298,7 @@ public void run() { RangePositionPileup pileup = new RangePositionPileup(i, position, options, exec); pileup.pileup(); - sb.append(pileup.toString()); + sb.append(pileup); } if (count % checkPoint == 0) { @@ -319,7 +314,7 @@ public void run() { countOutputSleep++; } catch (InterruptedException e) { logger.debug(Thread.currentThread().getName() + " " - + QBasePileupUtil.getStrackTrace(e) + " (queue size full) "); + + QBasePileupUtil.getStackTrace(e) + " (queue size full) "); } if (writeLatch.getCount() == 0) { logger.error("output queue is not empty but writing thread is complete"); @@ -335,7 +330,7 @@ public void run() { logger.info("Completed pileup thread: " + Thread.currentThread().getName()); } catch (Exception e) { - logger.error("Setting exit status in pileup thread to 1 as exception caught file: " + file + " " + QBasePileupUtil.getStrackTrace(e)); + logger.error("Setting exit status in pileup thread to 1 as exception caught file: " + file + " " + QBasePileupUtil.getStackTrace(e)); if (exitStatus.intValue() == 0) { exitStatus.incrementAndGet(); } @@ -388,7 +383,7 @@ public void run() { exitStatus.incrementAndGet(); } logger.info(Thread.currentThread().getName() + " " - + QBasePileupUtil.getStrackTrace(e)); + + QBasePileupUtil.getStackTrace(e)); } if ((count % checkPoint == 0) && (!mainThread.isAlive())) { @@ -412,7 +407,7 @@ public void run() { + resultsFile.getAbsolutePath()); } } catch (Exception e) { - logger.error("Setting exit status to 1 as exception caught in writing thread: " + QBasePileupUtil.getStrackTrace(e)); + logger.error("Setting exit status to 1 as exception caught in writing thread: " + QBasePileupUtil.getStackTrace(e)); if (exitStatus.intValue() == 0) { exitStatus.incrementAndGet(); } diff --git a/qbasepileup/src/org/qcmg/qbasepileup/coverage/RangePositionPileup.java b/qbasepileup/src/org/qcmg/qbasepileup/coverage/RangePositionPileup.java index 87f2cbbe1..da48a11c3 100644 --- a/qbasepileup/src/org/qcmg/qbasepileup/coverage/RangePositionPileup.java +++ b/qbasepileup/src/org/qcmg/qbasepileup/coverage/RangePositionPileup.java @@ -53,7 +53,7 @@ private Map setUpCountMap() { } public void pileup() throws Exception { - try (SamReader reader = SAMFileReaderFactory.createSAMFileReader(inputBam.getBamFile(), "silent");) { + try (SamReader reader = SAMFileReaderFactory.createSAMFileReader(inputBam.getBamFile(), "silent")) { SAMRecordIterator iterator = reader.queryOverlapping(position.getChromosome(), position.getStartPosition(), position.getEndPosition()); @@ -93,12 +93,8 @@ private boolean passesMaxCoverage(int coverageCount) { if (maxCoverage == null) { return true; } else { - if (coverageCount >= maxCoverage.intValue()) { - return true; - } + return coverageCount >= maxCoverage; } - - return false; } @Override diff --git a/qbasepileup/src/org/qcmg/qbasepileup/indel/Homopolymer.java b/qbasepileup/src/org/qcmg/qbasepileup/indel/Homopolymer.java index 385424bdb..de8c90f7b 100644 --- a/qbasepileup/src/org/qcmg/qbasepileup/indel/Homopolymer.java +++ b/qbasepileup/src/org/qcmg/qbasepileup/indel/Homopolymer.java @@ -61,26 +61,25 @@ public void findHomopolymer() { } } - private String getSequence() { + private void getSequence() { StringBuilder sb = new StringBuilder(); - - for (int i=0; i getHeader() throws IOException { -// List header = new ArrayList<>(); -// try (BufferedReader reader = new BufferedReader(new FileReader(inputFile))) { -// String line = null; -// while ((line=reader.readLine()) != null) { -// if (line.startsWith("#") || line.startsWith("analysis_id") || line.startsWith("Hugo") || line.startsWith("mutation")) { -// header.add(line); -// } else { -// break; -// } -// } -// } -// return header; -// } - private class Reading implements Runnable { private final AbstractQueue queue; @@ -173,7 +154,7 @@ public Reading(AbstractQueue readQueue, Thread mainThread, this.readLatch = readLatch; this.pileupLatch = filterLatch; this.inputFile = inputFile; - this.chromosomes = new ArrayList(); + this.chromosomes = new ArrayList<>(); } @Override @@ -181,7 +162,7 @@ public void run() { logger.info("Starting to read file: " + inputFile.getAbsolutePath()); int countSleep = 0; long count = 0; - try (BufferedReader reader = new BufferedReader(new FileReader(inputFile));) { + try (BufferedReader reader = new BufferedReader(new FileReader(inputFile))) { String line; @@ -214,7 +195,7 @@ public void run() { countSleep++; } catch (Exception e) { logger.info(Thread.currentThread().getName() - + " " + QBasePileupUtil.getStrackTrace(e)); + + " " + QBasePileupUtil.getStackTrace(e)); } } } @@ -223,7 +204,7 @@ public void run() { logger.info("Completed reading thread, read " + count + " records from input: " + inputFile.getAbsolutePath()); } catch (Exception e) { - logger.error("Setting exit status in execute thread to 1 as exception caught in reading method: " + QBasePileupUtil.getStrackTrace(e)); + logger.error("Setting exit status in execute thread to 1 as exception caught in reading method: " + QBasePileupUtil.getStackTrace(e)); if (exitStatus.intValue() == 0) { exitStatus.incrementAndGet(); } @@ -232,7 +213,7 @@ public void run() { readLatch.countDown(); logger.debug(String .format("Exit Reading thread, total slept %d times * %d milli-seconds, " - + "since input queue are full.fLatch is %d; queus size is %d ", + + "since input queue are full.fLatch is %d; queues size is %d ", countSleep, sleepUnit, pileupLatch.getCount(), queue.size())); } @@ -248,8 +229,7 @@ private class Pileup implements Runnable { private final CountDownLatch readLatch; private final CountDownLatch pileupLatch; private final CountDownLatch writeLatch; - private int countOutputSleep; - private final InputBAM tumourBam; + private final InputBAM tumourBam; private final InputBAM normalBam; private int maxLength = 110; private final File positionsFile; @@ -258,7 +238,7 @@ private class Pileup implements Runnable { public Pileup(AbstractQueue readQueue, AbstractQueue writeQueue, Thread mainThread, CountDownLatch readLatch, CountDownLatch pileupLatch, - CountDownLatch wGoodLatch, String positionsFile) throws Exception { + CountDownLatch wGoodLatch, String positionsFile) { this.queueIn = readQueue; this.queueOut = writeQueue; this.mainThread = mainThread; @@ -275,7 +255,7 @@ public void run() { int sleepcount = 0; int count = 0; - countOutputSleep = 0; + int countOutputSleep = 0; boolean run = true; IndexedFastaSequenceFile indexedFasta = QBasePileupUtil.getIndexedFastaFile(options.getReference()); try { @@ -296,8 +276,7 @@ public void run() { Thread.sleep(sleepUnit); sleepcount++; } catch (InterruptedException e) { - logger.info(Thread.currentThread().getName() + " " - + e.toString()); + logger.info(Thread.currentThread().getName() + " " + e); } } else { @@ -339,7 +318,7 @@ public void run() { countOutputSleep++; } catch (InterruptedException e) { logger.debug(Thread.currentThread().getName() + " " - + QBasePileupUtil.getStrackTrace(e) + " (queue size full) "); + + QBasePileupUtil.getStackTrace(e) + " (queue size full) "); } if (writeLatch.getCount() == 0) { logger.error("output queue is not empty but writing thread is complete"); @@ -350,14 +329,13 @@ public void run() { queueOut.add(outArray); } } - positionMap = null; - } + } } indexedFasta.close(); logger.info("Completed pileup thread: " + Thread.currentThread().getName()); } catch (Exception e) { - logger.error("Setting exit status in pileup thread to 1 as exception caught file: " + options.getReference() + " " + QBasePileupUtil.getStrackTrace(e)); + logger.error("Setting exit status in pileup thread to 1 as exception caught file: " + options.getReference() + " " + QBasePileupUtil.getStackTrace(e)); if (exitStatus.intValue() == 0) { exitStatus.incrementAndGet(); } @@ -395,14 +373,14 @@ private synchronized TreeMap> getPositionMap( positionCount.incrementAndGet(); IndelPosition p = null; - p = new IndelPosition(line, isGermline, indelFileType, dccColumns); + p = new IndelPosition(line, isGermline, dccColumns); if (p.getLength() > maxLength) { maxLength = p.getLength(); } IndelPositionPileup pileup = new IndelPositionPileup(tumourBam, normalBam, p, options, indexedFasta); if (p.getFullChromosome().equals(fullChr)) { - positionMap.computeIfAbsent(Integer.valueOf(p.getStart()), v -> new ArrayList<>()).add(pileup); + positionMap.computeIfAbsent(p.getStart(), v -> new ArrayList<>()).add(pileup); } } } @@ -412,7 +390,7 @@ private synchronized TreeMap> getPositionMap( private void pileupReads(InputBAM bam, String chromosome, TreeMap> positionMap, boolean isTumour) throws Exception { - try (SamReader reader = SAMFileReaderFactory.createSAMFileReader(bam.getBamFile(), "silent");) { + try (SamReader reader = SAMFileReaderFactory.createSAMFileReader(bam.getBamFile(), "silent")) { //get chromosome length String fullChromosome = QBasePileupUtil.getFullChromosome(chromosome); @@ -448,7 +426,7 @@ private void pileupReads(InputBAM bam, String chromosome, TreeMap> subMap = positionMap.subMap(start, end); - if (subMap != null && subMap.size() > 0) { + if (subMap.size() > 0) { for (Entry> entry: subMap.entrySet()) { for (IndelPositionPileup p : entry.getValue()) { @@ -470,8 +448,8 @@ private class Writing implements Runnable { private final CountDownLatch writeLatch; private final List headers; - public Writing(AbstractQueue q, File f, File pileupFile, Thread mainThread, - CountDownLatch fLatch, CountDownLatch wLatch, List headers) { + public Writing(AbstractQueue q, File f, Thread mainThread, + CountDownLatch fLatch, CountDownLatch wLatch, List headers) { queue = q; resultsFile = f; //this.pileupFile = pileupFile; @@ -490,7 +468,7 @@ public void run() { try { String[] record; int count = 0; - try (BufferedWriter writer = new BufferedWriter(new FileWriter(resultsFile));) { + try (BufferedWriter writer = new BufferedWriter(new FileWriter(resultsFile))) { while (run) { @@ -504,7 +482,7 @@ public void run() { exitStatus.incrementAndGet(); } logger.info(Thread.currentThread().getName() + " " - + QBasePileupUtil.getStrackTrace(e)); + + QBasePileupUtil.getStackTrace(e)); } if (filterLatch.getCount() == 0 && queue.size() == 0) { run = false; @@ -523,7 +501,7 @@ public void run() { } //rewrite in order - reorderFile(resultsFile, headers.stream().collect(Collectors.joining("\n"))); + reorderFile(resultsFile, String.join("\n", headers)); if (!mainThread.isAlive()) { @@ -537,7 +515,7 @@ public void run() { + resultsFile.getAbsolutePath()); } } catch (Exception e) { - logger.error("Setting exit status to 1 as exception caught in writing thread: " + QBasePileupUtil.getStrackTrace(e)); + logger.error("Setting exit status to 1 as exception caught in writing thread: " + QBasePileupUtil.getStackTrace(e)); if (exitStatus.intValue() == 0) { exitStatus.incrementAndGet(); } @@ -552,12 +530,12 @@ public void run() { private void reorderFile(File file, String header) throws IOException { Map map = new TreeMap<>(); - try (BufferedReader reader = new BufferedReader(new FileReader(file));) { + try (BufferedReader reader = new BufferedReader(new FileReader(file))) { String line = reader.readLine(); while(line != null) { String[] values = line.split("\t"); - map.put(new ChrRangePosition(values[4], Integer.valueOf(values[5]), Integer.valueOf(values[6])), line); + map.put(new ChrRangePosition(values[4], Integer.parseInt(values[5]), Integer.parseInt(values[6])), line); line = reader.readLine(); } } @@ -565,7 +543,7 @@ private void reorderFile(File file, String header) throws IOException { } private void printMap(Map map, File file, String header) throws IOException { - try (BufferedWriter writer = new BufferedWriter(new FileWriter(file));) { + try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) { writer.write(header); writer.newLine(); for (Entry entry: map.entrySet()) { diff --git a/qbasepileup/src/org/qcmg/qbasepileup/indel/IndelBasePileupMT.java b/qbasepileup/src/org/qcmg/qbasepileup/indel/IndelBasePileupMT.java index 5b6ab4098..ed7ff1889 100644 --- a/qbasepileup/src/org/qcmg/qbasepileup/indel/IndelBasePileupMT.java +++ b/qbasepileup/src/org/qcmg/qbasepileup/indel/IndelBasePileupMT.java @@ -24,7 +24,6 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; import htsjdk.samtools.reference.IndexedFastaSequenceFile; @@ -69,7 +68,7 @@ public int getExitStatus() { return this.exitStatus.intValue(); } - private void execute() throws Exception { + private void execute() { if (isGermline) { logger.info("**********PROCESSING GERMLINE FILE**********"); @@ -78,9 +77,9 @@ private void execute() throws Exception { logger.info("**********PROCESSING SOMATIC FILE**********"); } - final AbstractQueue readQueue = new ConcurrentLinkedQueue(); + final AbstractQueue readQueue = new ConcurrentLinkedQueue<>(); - final AbstractQueue writeQueue = new ConcurrentLinkedQueue(); + final AbstractQueue writeQueue = new ConcurrentLinkedQueue<>(); final CountDownLatch readLatch = new CountDownLatch(1); // reading // thread @@ -113,7 +112,7 @@ private void execute() throws Exception { pileupThreads.shutdown(); // kick-off single writing thread to output the satisfied Records - writeThread.execute(new Writing(writeQueue, outputFile, pileupFile, Thread.currentThread(), pileupLatch, writeLatch, headers)); + writeThread.execute(new Writing(writeQueue, outputFile, Thread.currentThread(), pileupLatch, writeLatch, headers)); writeThread.shutdown(); logger.info("waiting for threads to finish (max wait will be 100 hours)"); @@ -130,7 +129,7 @@ private void execute() throws Exception { logger.info("All threads finished"); } catch (Exception e) { - logger.info(QBasePileupUtil.getStrackTrace(e)); + logger.info(QBasePileupUtil.getStackTrace(e)); exitStatus.incrementAndGet(); } finally { // kill off any remaining threads @@ -140,22 +139,6 @@ private void execute() throws Exception { } } -// private List getHeader() throws IOException { -// -// List header = new ArrayList<>(); -// try (BufferedReader reader = new BufferedReader(new FileReader(inputFile));) { -// String line = null; -// while ((line=reader.readLine()) != null) { -// if (line.startsWith("#") || line.startsWith("analysis_id") || line.startsWith("Hugo") || line.startsWith("mutation")) { -// header.add(line); -// } else { -// break; -// } -// } -// } -// return header; -// } - private class Reading implements Runnable { private final AbstractQueue queue; @@ -172,7 +155,7 @@ public Reading(AbstractQueue q, Thread mainThread, this.readLatch = readLatch; this.pileupLatch = filterLatch; this.inputFile = inputFile; - this.positions = new ArrayList(); + this.positions = new ArrayList<>(); } @Override @@ -203,7 +186,7 @@ public void run() { IndelPosition p = null; - p = new IndelPosition(line, isGermline, indelFileType, dccColumns); + p = new IndelPosition(line, isGermline, dccColumns); if (!positions.contains(p)) { uniquePositionCount.incrementAndGet(); @@ -227,7 +210,7 @@ public void run() { countSleep++; } catch (Exception e) { logger.info(Thread.currentThread().getName() - + " " + QBasePileupUtil.getStrackTrace(e)); + + " " + QBasePileupUtil.getStackTrace(e)); } } } @@ -238,7 +221,7 @@ public void run() { logger.info("Completed reading thread, read " + count + " records from input: " + inputFile.getAbsolutePath()); } catch (Exception e) { - logger.error("Setting exit status in execute thread to 1 as exception caught in reading method: " + QBasePileupUtil.getStrackTrace(e)); + logger.error("Setting exit status in execute thread to 1 as exception caught in reading method: " + QBasePileupUtil.getStackTrace(e)); if (exitStatus.intValue() == 0) { exitStatus.incrementAndGet(); } @@ -263,15 +246,14 @@ private class Pileup implements Runnable { private final CountDownLatch readLatch; private final CountDownLatch pileupLatch; private final CountDownLatch writeLatch; - private int countOutputSleep; - private final InputBAM tumourBam; + private final InputBAM tumourBam; private final InputBAM normalBam; QueryExecutor exec = null; public Pileup(AbstractQueue queueIn, AbstractQueue writeQueue, Thread mainThread, CountDownLatch readLatch, CountDownLatch pileupLatch, - CountDownLatch wGoodLatch) throws Exception { + CountDownLatch wGoodLatch) { this.queueIn = queueIn; this.queueOut = writeQueue; this.mainThread = mainThread; @@ -287,7 +269,7 @@ public void run() { int sleepcount = 0; int count = 0; - countOutputSleep = 0; + int countOutputSleep = 0; boolean run = true; try { @@ -312,8 +294,7 @@ public void run() { Thread.sleep(sleepUnit); sleepcount++; } catch (InterruptedException e) { - logger.info(Thread.currentThread().getName() + " " - + e.toString()); + logger.info(Thread.currentThread().getName() + " " + e); } } else { @@ -343,7 +324,7 @@ public void run() { countOutputSleep++; } catch (InterruptedException e) { logger.debug(Thread.currentThread().getName() + " " - + QBasePileupUtil.getStrackTrace(e) + " (queue size full) "); + + QBasePileupUtil.getStackTrace(e) + " (queue size full) "); } if (writeLatch.getCount() == 0) { logger.error("output queue is not empty but writing thread is complete"); @@ -360,7 +341,7 @@ public void run() { logger.info("Completed pileup thread: " + Thread.currentThread().getName()); } catch (Exception e) { - logger.error("Setting exit status in pileup thread to 1 as exception caught file: " + options.getReference() + " " + QBasePileupUtil.getStrackTrace(e)); + logger.error("Setting exit status in pileup thread to 1 as exception caught file: " + options.getReference() + " " + QBasePileupUtil.getStackTrace(e)); if (exitStatus.intValue() == 0) { exitStatus.incrementAndGet(); } @@ -378,18 +359,16 @@ public void run() { private class Writing implements Runnable { private final File resultsFile; - //private final File pileupFile; private final AbstractQueue queue; private final Thread mainThread; private final CountDownLatch filterLatch; private final CountDownLatch writeLatch; private final List headers; - public Writing(AbstractQueue q, File f, File pileupFile, Thread mainThread, - CountDownLatch fLatch, CountDownLatch wLatch, List headers) { + public Writing(AbstractQueue q, File f, Thread mainThread, + CountDownLatch fLatch, CountDownLatch wLatch, List headers) { queue = q; resultsFile = f; - //this.pileupFile = pileupFile; this.mainThread = mainThread; this.filterLatch = fLatch; this.writeLatch = wLatch; @@ -419,7 +398,7 @@ public void run() { exitStatus.incrementAndGet(); } logger.info(Thread.currentThread().getName() + " " - + QBasePileupUtil.getStrackTrace(e)); + + QBasePileupUtil.getStackTrace(e)); } if (filterLatch.getCount() == 0 && queue.size() == 0) { @@ -441,7 +420,7 @@ public void run() { writer.close(); //rewrite in order - reorderFile(resultsFile, headers.stream().collect(Collectors.joining("\n"))); + reorderFile(resultsFile, String.join("\n", headers)); if (!mainThread.isAlive()) { @@ -455,7 +434,7 @@ public void run() { + resultsFile.getAbsolutePath()); } } catch (Exception e) { - logger.error("Setting exit status to 1 as exception caught in writing thread: " + QBasePileupUtil.getStrackTrace(e)); + logger.error("Setting exit status to 1 as exception caught in writing thread: " + QBasePileupUtil.getStackTrace(e)); if (exitStatus.intValue() == 0) { exitStatus.incrementAndGet(); } @@ -468,12 +447,12 @@ public void run() { } private void reorderFile(File file, String header) throws IOException { - Map map = new TreeMap(); + Map map = new TreeMap<>(); try (BufferedReader reader = new BufferedReader(new FileReader(file))) { - String line = reader.readLine();; + String line = reader.readLine(); while(line != null) { String[] values = line.split("\t"); - map.put(new ChrRangePosition(values[4], Integer.valueOf(values[5]), Integer.valueOf(values[6])), line); + map.put(new ChrRangePosition(values[4], Integer.parseInt(values[5]), Integer.parseInt(values[6])), line); line = reader.readLine(); } } diff --git a/qbasepileup/src/org/qcmg/qbasepileup/indel/IndelPileup.java b/qbasepileup/src/org/qcmg/qbasepileup/indel/IndelPileup.java index 446b49bbf..363036897 100644 --- a/qbasepileup/src/org/qcmg/qbasepileup/indel/IndelPileup.java +++ b/qbasepileup/src/org/qcmg/qbasepileup/indel/IndelPileup.java @@ -49,9 +49,8 @@ public class IndelPileup { private static final String SCOLON = ";"; private Homopolymer homopolymer; private boolean highCoverage; - private Map records = new HashMap(); + private Map records = new HashMap<>(); private final Options options; - private final File referenceFile; public IndelPileup(Options options,InputBAM inputBam, IndelPosition position, File reference, int softClipWindow, int homopolymerWindow, int nearbyIndelWindow, boolean isTumour) throws QBasePileupException { this.inputBam = inputBam; @@ -60,7 +59,6 @@ public IndelPileup(Options options,InputBAM inputBam, IndelPosition position, Fi this.homopolymerWindow = homopolymerWindow; this.nearbyIndelWindow = nearbyIndelWindow; this.isTumour = isTumour; - this.referenceFile = reference; this.options = options; } @@ -82,7 +80,7 @@ public void pileupRead(SAMRecord r) { public void pileupReads(QueryExecutor exec, IndexedFastaSequenceFile indexedFasta) throws Exception { // setDefaultValidationStringency(); - try (SamReader reader = SAMFileReaderFactory.createSAMFileReader(inputBam.getBamFile(), null, ValidationStringency.SILENT);) { //new SAMFileReader(inputBam.getBamFile()); + try (SamReader reader = SAMFileReaderFactory.createSAMFileReader(inputBam.getBamFile(), null, ValidationStringency.SILENT)) { //new SAMFileReader(inputBam.getBamFile()); SAMRecordIterator iter = reader.queryOverlapping(position.getFullChromosome(), position.getStart(), position.getEnd()); boolean passFilter; while (iter.hasNext()) { @@ -146,12 +144,12 @@ private void filterSAMRecord(SAMRecord record) { } else if (position.isInsertion()){ parseInsertionIndel(record, maskedReadBases); } else { - parseComplexIndel(record, maskedReadBases); + parseComplexIndel(record); } } } - public void parseComplexIndel(SAMRecord record, byte[] maskedReadBases) { + public void parseComplexIndel(SAMRecord record) { informativeReads++; boolean indelPresent = false; @@ -199,9 +197,7 @@ public boolean inSoftClipWindow(SAMRecord record) { if (record.getAlignmentEnd() != record.getUnclippedEnd()) { int clipEndPosition = record.getAlignmentEnd()+1; //clip start position is in the window to the left of the indel - if (clipEndPosition >= windowStart && clipEndPosition <= windowEnd) { - return true; - } + return clipEndPosition >= windowStart && clipEndPosition <= windowEnd; } return false; } @@ -289,14 +285,13 @@ public boolean nearbyIndel(SAMRecord record) { indelStart = position.getStart()-1; indelEnd = position.getEnd()+1; windowStart = Math.max(record.getAlignmentStart(), indelStart-nearbyIndelWindow+1); - windowEnd = Math.min(record.getAlignmentEnd(), indelEnd+ nearbyIndelWindow-1); } else { indelStart = position.getStart(); indelEnd = position.getEnd(); windowStart = Math.max(record.getAlignmentStart(), indelStart-nearbyIndelWindow); - windowEnd = Math.min(record.getAlignmentEnd(), indelEnd+ nearbyIndelWindow-1); } - + windowEnd = Math.min(record.getAlignmentEnd(), indelEnd+ nearbyIndelWindow-1); + int refPos = record.getAlignmentStart(); for (CigarElement ce : cigar.getCigarElements()) { int cigarLength = ce.getLength(); @@ -449,7 +444,7 @@ public boolean cigarOperatorAtReadPostion(SAMRecord record, CigarOperator operat break; } if (operator == ce.getOperator()) { - if (readIndexToFind >= readIndex && readIndexToFind < (readIndex+cigarLength)) { + if (readIndexToFind < readIndex+cigarLength) { return true; } } @@ -518,10 +513,6 @@ public void setInformativeReads(int informativeReads) { this.informativeReads = informativeReads; } - public int getNearbySoftClipCount() { - return nearbySoftClipCount; - } - public void setNearbySoftClipCount(int nearbySoftClipCount) { this.nearbySoftClipCount = nearbySoftClipCount; } @@ -606,23 +597,15 @@ public String toDCCString() { // + SCOLON + reverseSupportingReads; if (isTumour && homopolymer != null) { - s += SCOLON + homopolymer.toString(); + s += SCOLON + homopolymer; } return s; } - public int getForwardSupportingReads() { - return forwardSupportingReads; - } - public void setForwardSupportingReads(int forwardSupportingReads) { this.forwardSupportingReads = forwardSupportingReads; } - public int getReverseSupportingReads() { - return reverseSupportingReads; - } - public void setReverseSupportingReads(int reverseSupportingReads) { this.reverseSupportingReads = reverseSupportingReads; } @@ -649,10 +632,8 @@ public boolean hasStrandBias() { } double forwardPercent = getPercentForwardSupportingReads(); double reversePercent = getPercentReverseSupportingReads(); - if (forwardPercent < minPercent || forwardPercent > maxPercent - || reversePercent < minPercent || reversePercent > maxPercent) { - return true; - } + return forwardPercent < minPercent || forwardPercent > maxPercent + || reversePercent < minPercent || reversePercent > maxPercent; } return false; diff --git a/qbasepileup/src/org/qcmg/qbasepileup/indel/IndelPosition.java b/qbasepileup/src/org/qcmg/qbasepileup/indel/IndelPosition.java index a1171731f..143628bc4 100644 --- a/qbasepileup/src/org/qcmg/qbasepileup/indel/IndelPosition.java +++ b/qbasepileup/src/org/qcmg/qbasepileup/indel/IndelPosition.java @@ -18,9 +18,7 @@ public class IndelPosition { Integer start; Integer end; int length; - private String name; private final String fullChromosome; - private final String indelFileType; public static final String DEL = "DEL"; public static final String INS = "INS"; public static final String CTX = "CTX"; @@ -33,17 +31,15 @@ public class IndelPosition { private String motif; QLogger logger = QLoggerFactory.getLogger(IndelPosition.class); - public IndelPosition(String line, boolean isGermline, String indelFileType, int[] dccColumns) { - String[] values = line.split("\t"); - - String mut = values[3]; - if (mut.equals("2")) { - mut = INS; - } else if (mut.equals("3")) { - mut = DEL; - } else if (mut.equals("4")) { - mut = CTX; - } + public IndelPosition(String line, boolean isGermline, int[] dccColumns) { + String[] values = line.split("\t"); + + String mut = switch (values[3]) { + case "2" -> INS; + case "3" -> DEL; + case "4" -> CTX; + default -> values[3]; + }; this.qcmgFlagColumn = dccColumns[0]; this.ndColumn = dccColumns[1]; this.tdColumn = dccColumns[2]; @@ -51,10 +47,9 @@ public IndelPosition(String line, boolean isGermline, String indelFileType, int[ this.fullChromosome = QBasePileupUtil.getFullChromosome(chromosome); this.mutationType = mut; this.isGermline = isGermline; - this.start = new Integer(values[5]); + this.start = Integer.valueOf(values[5]); - this.end = new Integer(values[6]); - this.indelFileType = indelFileType; + this.end = Integer.valueOf(values[6]); this.inputString = line; this.motif = getMotif(values[dccColumns[3]], values[dccColumns[4]]); this.length = motif.length(); @@ -72,14 +67,13 @@ private String getMotif(String referenceBases, String tumourBases) { } } - public IndelPosition(String name, String chromosome, Integer start, Integer end, String mutationType, String indelFileType, String line, boolean isGermline, String motif) { + public IndelPosition(String chromosome, Integer start, Integer end, String mutationType, String indelFileType, String line, boolean isGermline) { super(); this.chromosome = chromosome; this.fullChromosome = QBasePileupUtil.getFullChromosome(chromosome); this.mutationType = mutationType; this.isGermline = isGermline; -// setMotif(motif); - + if (indelFileType.equals("pindel") || indelFileType.equals("strelka")) { if (mutationType.equals(INS) || mutationType.equals(CTX)) { @@ -93,11 +87,9 @@ public IndelPosition(String name, String chromosome, Integer start, Integer end, this.end = end - 1; this.length = end -start + 1; } - } - - this.name = name; - this.indelFileType = indelFileType; - this.inputString = line; + } + + this.inputString = line; } public String getMutationType() { @@ -117,13 +109,13 @@ public String getChromosome() { return chromosome; } public int getStart() { - return start.intValue(); + return start; } public Integer getStartObject() { return start; } public int getEnd() { - return end.intValue(); + return end; } public int getLength() { return length; @@ -136,11 +128,9 @@ public String getFullChromosome() { @Override public boolean equals(final Object o) { - if (!(o instanceof IndelPosition)) return false; - - final IndelPosition other = (IndelPosition) o; - - if (chromosome.equals(other.getChromosome())) { + if (!(o instanceof IndelPosition other)) return false; + + if (chromosome.equals(other.getChromosome())) { if (start.equals(other.getStartObject())) { return end.equals(other.getEnd()); } else { diff --git a/qbasepileup/src/org/qcmg/qbasepileup/indel/IndelPositionPileup.java b/qbasepileup/src/org/qcmg/qbasepileup/indel/IndelPositionPileup.java index ca8588227..aa8514070 100644 --- a/qbasepileup/src/org/qcmg/qbasepileup/indel/IndelPositionPileup.java +++ b/qbasepileup/src/org/qcmg/qbasepileup/indel/IndelPositionPileup.java @@ -19,15 +19,13 @@ public class IndelPositionPileup { private IndelPosition position; - private IndelPileup tumourPileup; - private IndelPileup normalPileup; + private final IndelPileup tumourPileup; + private final IndelPileup normalPileup; private String pileupFlags = ""; - private final Options options; private final IndexedFastaSequenceFile indexedFasta; public IndelPositionPileup(InputBAM tumourBam, InputBAM normalBam, org.qcmg.qbasepileup.indel.IndelPosition position, Options options, IndexedFastaSequenceFile indexedFastaFile) throws QBasePileupException { this.position = position; - this.options = options; this.indexedFasta = indexedFastaFile; tumourPileup = new IndelPileup(options, tumourBam, position, options.getReference(), options.getSoftClipWindow(), options.getNearbyHomopolymerWindow(), options.getNearbyIndelWindow(), true); normalPileup = new IndelPileup(options, normalBam, position, options.getReference(), options.getSoftClipWindow(), options.getNearbyHomopolymerWindow(), options.getNearbyIndelWindow(), false); @@ -45,18 +43,10 @@ public IndelPileup getTumourPileup() { return tumourPileup; } - public void setTumourPileup(IndelPileup tumourPileup) { - this.tumourPileup = tumourPileup; - } - public IndelPileup getNormalPileup() { return normalPileup; } - public void setNormalPileup(IndelPileup normalPileup) { - this.normalPileup = normalPileup; - } - //pileup reads by query bam across indel positions public void pileupReads(QueryExecutor exec) throws Exception { tumourPileup.pileupReads(exec, indexedFasta); @@ -124,13 +114,11 @@ public String calculatePileupFlags() { if (hp != null && !hp.getHomopolymerCount().equals("ne")) { String type = hp.getType(); String count = hp.getHomopolymerCount(); - if (type.equals(Homopolymer.DISCONTIGUOUS)) { - flags.append("HOMADJ_" + count); - } else if (type.equals(Homopolymer.CONTIGUOUS)) { - flags.append("HOMCON_" + count); - } else if (type.equals(Homopolymer.EMBEDDED)) { - flags.append("HOMEMB_" + count); - } + switch (type) { + case Homopolymer.DISCONTIGUOUS -> flags.append("HOMADJ_").append(count); + case Homopolymer.CONTIGUOUS -> flags.append("HOMCON_").append(count); + case Homopolymer.EMBEDDED -> flags.append("HOMEMB_").append(count); + } } String flagStr = flags.toString(); @@ -182,10 +170,6 @@ public void finish() { normalPileup.finish(indexedFasta); this.pileupFlags = calculatePileupFlags(); } - - public String getPileupFlags() { - return pileupFlags; - } public void setPileupFlags(String pileupFlags) { this.pileupFlags = pileupFlags; diff --git a/qbasepileup/src/org/qcmg/qbasepileup/snp/SnpBasePileupByFileMT.java b/qbasepileup/src/org/qcmg/qbasepileup/snp/SnpBasePileupByFileMT.java index da0502de4..ecdbb11ba 100644 --- a/qbasepileup/src/org/qcmg/qbasepileup/snp/SnpBasePileupByFileMT.java +++ b/qbasepileup/src/org/qcmg/qbasepileup/snp/SnpBasePileupByFileMT.java @@ -29,8 +29,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import htsjdk.samtools.reference.FastaSequenceIndex; -import htsjdk.samtools.reference.IndexedFastaSequenceFile; import htsjdk.samtools.SamReader; import htsjdk.samtools.SAMRecord; @@ -130,7 +128,7 @@ private void execute() throws IOException { logger.info("All threads finished"); } catch (Exception e) { - logger.info(QBasePileupUtil.getStrackTrace(e)); + logger.info(QBasePileupUtil.getStackTrace(e)); exitStatus.incrementAndGet(); } finally { // kill off any remaining threads @@ -305,7 +303,7 @@ public void run() { logger.info("Completed pileup thread: " + Thread.currentThread().getName()); } catch (Exception e) { - logger.error("Setting exit status in pileup thread to 1 as exception caught file: " + file + " " + QBasePileupUtil.getStrackTrace(e)); + logger.error("Setting exit status in pileup thread to 1 as exception caught file: " + file + " " + QBasePileupUtil.getStackTrace(e)); if (exitStatus.intValue() == 0) { exitStatus.incrementAndGet(); } @@ -336,7 +334,7 @@ private boolean writeMap(TreeMap> chrMap, long countOutputSleep++; } catch (InterruptedException e) { logger.debug(Thread.currentThread().getName() + " " - + QBasePileupUtil.getStrackTrace(e) + " (queue size full) "); + + QBasePileupUtil.getStackTrace(e) + " (queue size full) "); } if (writeLatch.getCount() == 0) { logger.error("output queue is not empty but writing thread is complete"); @@ -425,7 +423,7 @@ public void run() { exitStatus.incrementAndGet(); } logger.info(Thread.currentThread().getName() + " " - + QBasePileupUtil.getStrackTrace(e)); + + QBasePileupUtil.getStackTrace(e)); } if (filterLatch.getCount() == 0 && queue.size() == 0) { run = false; @@ -510,7 +508,7 @@ public void run() { + resultsFile.getAbsolutePath()); } } catch (Exception e) { - logger.error("Setting exit status to 1 as exception caught in writing thread: " + QBasePileupUtil.getStrackTrace(e)); + logger.error("Setting exit status to 1 as exception caught in writing thread: " + QBasePileupUtil.getStackTrace(e)); if (exitStatus.intValue() == 0) { exitStatus.incrementAndGet(); } diff --git a/qbasepileup/src/org/qcmg/qbasepileup/snp/SnpBasePileupMT.java b/qbasepileup/src/org/qcmg/qbasepileup/snp/SnpBasePileupMT.java index 51210004e..553f10b0d 100644 --- a/qbasepileup/src/org/qcmg/qbasepileup/snp/SnpBasePileupMT.java +++ b/qbasepileup/src/org/qcmg/qbasepileup/snp/SnpBasePileupMT.java @@ -6,43 +6,19 @@ */ package org.qcmg.qbasepileup.snp; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.util.AbstractQueue; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; - import htsjdk.samtools.SamReader; -import htsjdk.samtools.SAMRecordIterator; - import org.qcmg.common.log.QLogger; import org.qcmg.common.log.QLoggerFactory; import org.qcmg.common.model.ReferenceNameComparator; import org.qcmg.common.util.Constants; import org.qcmg.qbamfilter.query.QueryExecutor; -import org.qcmg.qbasepileup.InputBAM; -import org.qcmg.qbasepileup.Options; -import org.qcmg.qbasepileup.QBasePileupConstants; -import org.qcmg.qbasepileup.QBasePileupException; -import org.qcmg.qbasepileup.QBasePileupUtil; +import org.qcmg.qbasepileup.*; + +import java.io.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; public class SnpBasePileupMT { @@ -106,13 +82,10 @@ private void execute() throws IOException { final ReferenceNameComparator refNameComp = new ReferenceNameComparator(); - final Set uniqueSnpPositions = new TreeSet<>(new Comparator() { - @Override - public int compare(SnpPosition o1, SnpPosition o2) { - int chrDiff = refNameComp.compare(o1.getFullChromosome(), o2.getFullChromosome()); - if (chrDiff != 0) return chrDiff; - return o1.getStart() - o2.getStart(); - } + final Set uniqueSnpPositions = new TreeSet<>((o1, o2) -> { + int chrDiff = refNameComp.compare(o1.getFullChromosome(), o2.getFullChromosome()); + if (chrDiff != 0) return chrDiff; + return o1.getStart() - o2.getStart(); }); uniqueSnpPositions.addAll(positions); @@ -121,7 +94,7 @@ public int compare(SnpPosition o1, SnpPosition o2) { for (int i = 0; i < threadNo; i++) { pileupThreads.execute(new Pileup(readQueue, writeQueue, Thread.currentThread(), - pileupLatch, writeLatch, options.getInputBAMs(), uniqueSnpPositions)); + pileupLatch, writeLatch, options.getInputBAMs())); } pileupThreads.shutdown(); @@ -131,13 +104,13 @@ public int compare(SnpPosition o1, SnpPosition o2) { writeThread.shutdown(); logger.info("waiting for threads to finish (max wait will be 100 hours)"); - pileupThreads.awaitTermination(Constants.EXECUTOR_SERVICE_AWAIT_TERMINATION, TimeUnit.HOURS); - writeThread.awaitTermination(Constants.EXECUTOR_SERVICE_AWAIT_TERMINATION, TimeUnit.HOURS); + pileupThreads.awaitTermination(Constants.EXECUTOR_SERVICE_AWAIT_TERMINATION, java.util.concurrent.TimeUnit.HOURS); + writeThread.awaitTermination(Constants.EXECUTOR_SERVICE_AWAIT_TERMINATION, java.util.concurrent.TimeUnit.HOURS); logger.info("All threads finished"); } catch (Exception e) { - logger.info(QBasePileupUtil.getStrackTrace(e)); + logger.info(QBasePileupUtil.getStackTrace(e)); exitStatus.incrementAndGet(); } finally { // kill off any remaining threads @@ -147,7 +120,7 @@ public int compare(SnpPosition o1, SnpPosition o2) { logger.debug("TOTAL POSITIONS: \t\t\t" + positionCount); logger.debug("UNIQUE POSITIONS: \t\t\t" + new HashSet<>(positions).size()); - logger.debug("TOTAL READS EXAMINED:\t\t"+totalExamined+""); + logger.debug("TOTAL READS EXAMINED:\t\t"+totalExamined); logger.debug("---------------------------------------------"); logger.debug("TOTAL READS KEPT:\t\t"+totalPassedFilters); logger.debug("TOTAL READS NOT ON SNP:\t\t"+totalReadsNotMapped); @@ -175,11 +148,10 @@ public Reading(AbstractQueue q, Thread mainThread, @Override public void run() { logger.info("Starting to read positions file: " + positionsFile.getAbsolutePath()); - int countSleep = 0; long count = 0; boolean outputFormat2 = options.getOutputFormat() == 2; - try (BufferedReader reader = new BufferedReader(new FileReader(positionsFile));) { + try (BufferedReader reader = new BufferedReader(new FileReader(positionsFile))) { String line; int mutationColumn = -1; @@ -224,7 +196,7 @@ public void run() { logger.info("Completed reading thread, read " + count + " records from input: " + positionsFile.getAbsolutePath()); } catch (Exception e) { - logger.error("Setting exit status in execute thread to 1 as exception caught in reading method: " + QBasePileupUtil.getStrackTrace(e)); + logger.error("Setting exit status in execute thread to 1 as exception caught in reading method: " + QBasePileupUtil.getStackTrace(e)); if (exitStatus.intValue() == 0) { exitStatus.incrementAndGet(); } @@ -242,26 +214,21 @@ private class Pileup implements Runnable { private final Thread mainThread; private final CountDownLatch pileupLatch; private final CountDownLatch writeLatch; - private int countOutputSleep; private final List currentInputs; - private final Set snpPositions; private final String file = null; private QueryExecutor exec = null; public Pileup(AbstractQueue queueIn, AbstractQueue queueOut, Thread mainThread, CountDownLatch pileupLatch, - CountDownLatch wGoodLatch, List inputs, Set uniqueSnps) { + CountDownLatch wGoodLatch, List inputs) { this.queueIn = queueIn; this.queueOut = queueOut; this.mainThread = mainThread; this.pileupLatch = pileupLatch; this.writeLatch = wGoodLatch; this.currentInputs = new ArrayList<>(); - for (InputBAM i : inputs) { - currentInputs.add(i); - } - this.snpPositions = uniqueSnps; + currentInputs.addAll(inputs); } @Override @@ -269,7 +236,7 @@ public void run() { int sleepcount = 0; int count = 0; - countOutputSleep = 0; + int countOutputSleep = 0; boolean run = true; if (options.getFilterQuery() != null) { @@ -280,10 +247,7 @@ public void run() { e.printStackTrace(); } } - - SAMRecordIterator iter = null; - SamReader reader = null; - + try { SnpPosition position; @@ -299,7 +263,7 @@ public void run() { sleepcount++; } catch (InterruptedException e) { logger.info(Thread.currentThread().getName() + " " - + e.toString()); + + e); } // must check whether reading thread finished first. @@ -331,11 +295,11 @@ public void run() { if (options.getOutputFormat() == 2) { queueOut.add(pileup.toColumnString()); } else { - queueOut.add(pileup.toString() + "\n"); + queueOut.add(pileup + "\n"); } } if (options.getMode().equals(QBasePileupConstants.COMPOUND_SNP_MODE)) { - sb.append(pileup.toCompoundString() + "\n"); + sb.append(pileup.toCompoundString()).append("\n"); } if (options.getMode().equals(QBasePileupConstants.SNP_CHECK_MODE)) { queueOut.add(pileup.toMafString() + "\n"); @@ -359,7 +323,7 @@ public void run() { countOutputSleep++; } catch (InterruptedException e) { logger.debug(Thread.currentThread().getName() + " " - + QBasePileupUtil.getStrackTrace(e) + " (queue size full) "); + + QBasePileupUtil.getStackTrace(e) + " (queue size full) "); } if (writeLatch.getCount() == 0) { logger.error("output queue is not empty but writing thread is complete"); @@ -374,7 +338,7 @@ public void run() { logger.info("Completed pileup thread: " + Thread.currentThread().getName()); } catch (Exception e) { - logger.error("Setting exit status in pileup thread to 1 as exception caught file: " + file + " " + QBasePileupUtil.getStrackTrace(e)); + logger.error("Setting exit status in pileup thread to 1 as exception caught file: " + file + " " + QBasePileupUtil.getStackTrace(e)); if (exitStatus.intValue() == 0) { exitStatus.incrementAndGet(); } @@ -413,7 +377,7 @@ public void run() { try { String record; int count = 0; - try (BufferedWriter writer = new BufferedWriter(new FileWriter(resultsFile));) { + try (BufferedWriter writer = new BufferedWriter(new FileWriter(resultsFile))) { Map> inputMap = new HashMap<>(); writer.write(getHeader()); @@ -429,7 +393,7 @@ public void run() { exitStatus.incrementAndGet(); } logger.info(Thread.currentThread().getName() + " " - + QBasePileupUtil.getStrackTrace(e)); + + QBasePileupUtil.getStackTrace(e)); } if (filterLatch.getCount() == 0 && queue.size() == 0) { run = false; @@ -447,7 +411,7 @@ public void run() { String info = Arrays.stream(vals, 7, vals.length).collect(Collectors.joining(Constants.TAB_STRING)); String bam = vals[6]; - inputMap.computeIfAbsent(position, f -> new HashMap()).put(bam, info); + inputMap.computeIfAbsent(position, f -> new HashMap<>()).put(bam, info); } else { writer.write(record); } @@ -495,10 +459,10 @@ public void run() { sb.append(TAB); } } - writer.write(sb.toString() + "\n"); + writer.write(sb + "\n"); } } else { - logger.warn("The following entries in the positions file did not have any results - incorrect reference bases?\n" + positionsMissingInMap.toString()); + logger.warn("The following entries in the positions file did not have any results - incorrect reference bases?\n" + positionsMissingInMap); throw new QBasePileupException("POSITION_FILE_ERROR"); } } @@ -515,7 +479,7 @@ public void run() { + resultsFile.getAbsolutePath()); } } catch (Exception e) { - logger.error("Setting exit status to 1 as exception caught in writing thread: " + QBasePileupUtil.getStrackTrace(e)); + logger.error("Setting exit status to 1 as exception caught in writing thread: " + QBasePileupUtil.getStackTrace(e)); if (exitStatus.intValue() == 0) { exitStatus.incrementAndGet(); } diff --git a/qbasepileup/src/org/qcmg/qbasepileup/snp/SnpPosition.java b/qbasepileup/src/org/qcmg/qbasepileup/snp/SnpPosition.java index ebb1c95f4..88bb1b0bf 100644 --- a/qbasepileup/src/org/qcmg/qbasepileup/snp/SnpPosition.java +++ b/qbasepileup/src/org/qcmg/qbasepileup/snp/SnpPosition.java @@ -6,15 +6,13 @@ */ package org.qcmg.qbasepileup.snp; -import java.io.File; -import java.io.IOException; - import org.qcmg.common.model.ChrPosition; import org.qcmg.common.model.ChrRangePosition; import org.qcmg.picard.ReferenceUtils; -import org.qcmg.qbasepileup.QBasePileupException; import org.qcmg.qbasepileup.QBasePileupUtil; +import java.io.File; + public class SnpPosition { public static final char TAB = '\t'; @@ -97,11 +95,8 @@ public boolean equals(Object obj) { } else if (!chrPos.equals(other.chrPos)) return false; if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; + return other.name == null; + } else return name.equals(other.name); } public String toTabString() { @@ -117,7 +112,7 @@ public String toString() { return getChromosome() + ":" + getStart() + "-" + getEnd(); } - public void retrieveReferenceBases(File refFile) throws QBasePileupException, IOException { + public void retrieveReferenceBases(File refFile) { referenceBases = ReferenceUtils.getReferenceBases(refFile, fullChromosome, getStart(), getEnd()); } diff --git a/qbasepileup/src/org/qcmg/qbasepileup/snp/SnpPositionPileup.java b/qbasepileup/src/org/qcmg/qbasepileup/snp/SnpPositionPileup.java index bd569b817..a9939f2ec 100644 --- a/qbasepileup/src/org/qcmg/qbasepileup/snp/SnpPositionPileup.java +++ b/qbasepileup/src/org/qcmg/qbasepileup/snp/SnpPositionPileup.java @@ -436,8 +436,8 @@ private void addToMap(String key, Map map) { public boolean basesAreMapped() { if (readBases != null) { - for (int i=0; i keys = new TreeSet(forNovelStartMap.keySet()); + Set keys = new TreeSet<>(forNovelStartMap.keySet()); keys.addAll(revNovelStartMap.keySet()); for (String key: keys) { @@ -619,10 +619,8 @@ public String toString() { } public String toColumnString() { - StringBuilder b = new StringBuilder(position.toOutputColumnsString()); - b.append(TAB); - b.append(input.getAbbreviatedBamFileName()).append(TAB).append(getAllBaseCounts(forCoverageMap, revCoverageMap)); - return b.toString(); + return position.toOutputColumnsString() + TAB + + input.getAbbreviatedBamFileName() + TAB + getAllBaseCounts(forCoverageMap, revCoverageMap); } private String getAllBaseCounts(Map forCoverageMap, Map revCoverageMap) { diff --git a/qbasepileup/test/org/qcmg/qbasepileup/indel/HomopolymerTest.java b/qbasepileup/test/org/qcmg/qbasepileup/indel/HomopolymerTest.java index 5af0b27c2..2e2c38d41 100644 --- a/qbasepileup/test/org/qcmg/qbasepileup/indel/HomopolymerTest.java +++ b/qbasepileup/test/org/qcmg/qbasepileup/indel/HomopolymerTest.java @@ -232,7 +232,7 @@ private void assertSequenceEquals(String expected, byte[] sequenceArray) { } private Homopolymer getHomopolymerObject(String chr, Integer start, Integer end, String mutationType, String indelBases) { - IndelPosition p = new IndelPosition("1", chr, start, end, mutationType, "pindel", "", false, indelBases); + IndelPosition p = new IndelPosition(chr, start, end, mutationType, "pindel", "", false); Homopolymer hp = new Homopolymer(p, indexedFastaFile, hompolymerWindow); p.setMotif(indelBases); diff --git a/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelBasePileupMTTest.java b/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelBasePileupMTTest.java index 5b5ef247f..64d53c9d1 100644 --- a/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelBasePileupMTTest.java +++ b/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelBasePileupMTTest.java @@ -144,7 +144,7 @@ public void testIndelBasePileupByChrMT() throws Exception { String[] args = {"--log", log, "-it", bamFile, "-in", bamFile, "-r", reference, "-os", output, "-is", snps, "-m", "indel", "--pindel"}; Options options = new Options(args); - new IndelBasePileupByChrMT(options.getSomaticIndelFile(), options.getSomaticOutputFile(), null, false, options); + new IndelBasePileupByChrMT(options.getSomaticIndelFile(), options.getSomaticOutputFile(), false, options); assertTrue(new File(output).exists()); try (BufferedReader reader = new BufferedReader(new FileReader(new File(output)));) { @@ -181,7 +181,7 @@ public void testIndelBasePileupByChrMTWithFilter() throws Exception { String[] args = {"--log", log, "-it", bamFile, "-in", bamFile, "-r", reference, "-os", output, "-is", snps, "-m", "indel", "--pindel", "--filter", "option_SM > 30"}; Options options = new Options(args); assertEquals("option_SM > 30", options.getFilterQuery()); - new IndelBasePileupByChrMT(options.getSomaticIndelFile(), options.getSomaticOutputFile(), null, false, options); + new IndelBasePileupByChrMT(options.getSomaticIndelFile(), options.getSomaticOutputFile(), false, options); assertTrue(new File(output).exists()); try (BufferedReader reader = new BufferedReader(new FileReader(new File(output)));) { diff --git a/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPileupForDeletionTest.java b/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPileupForDeletionTest.java index 000845607..486ac9495 100644 --- a/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPileupForDeletionTest.java +++ b/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPileupForDeletionTest.java @@ -41,7 +41,7 @@ public void setUp() throws QBasePileupException, IOException { Options options = createMock(Options.class); expect(options.includeDuplicates()).andReturn(false); replay(options); - position = new IndelPosition(line, false, "pindel", cols); + position = new IndelPosition(line, false, cols); pileup = new IndelPileup(options, new InputBAM(testFolder.newFile("tumour.bam")), position, testFolder.newFile("reference.fa"), 5, 10, 3, true); record = new SAMRecord(null); record.setAlignmentStart(1000); @@ -157,7 +157,7 @@ public void testGetDeletionIndelLength() throws QBasePileupException, IOExceptio Options options = createMock(Options.class); expect(options.includeDuplicates()).andReturn(false); replay(options); - position = new IndelPosition(line, false, "pindel", cols); + position = new IndelPosition(line, false, cols); pileup = new IndelPileup(options, new InputBAM(testFolder.newFile("tumour1.bam")), position, testFolder.newFile("reference1.fa"), 5, 10, 3, true); record.setCigarString("8M1D92M"); @@ -186,7 +186,7 @@ public void testParseDeletionIndelWithPartialDeletion() throws QBasePileupExcept Options options = createMock(Options.class); expect(options.includeDuplicates()).andReturn(false); replay(options); - position = new IndelPosition(line, false, "pindel", cols); + position = new IndelPosition(line, false, cols); pileup = new IndelPileup(options, new InputBAM(testFolder.newFile("tumour1.bam")), position, testFolder.newFile("reference1.fa"), 5, 10, 3, true); diff --git a/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPileupForInsertionTest.java b/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPileupForInsertionTest.java index 52093e648..26820dfc8 100644 --- a/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPileupForInsertionTest.java +++ b/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPileupForInsertionTest.java @@ -40,7 +40,7 @@ public void setUp() throws QBasePileupException, IOException { Options options = createMock(Options.class); expect(options.includeDuplicates()).andReturn(false); replay(options); - position = new IndelPosition(line, false, "pindel", cols); + position = new IndelPosition(line, false, cols); pileup = new IndelPileup(options, new InputBAM(testFolder.newFile("tumour.bam")), position, testFolder.newFile("reference.fa"), 5, 10, 3, true); record = new SAMRecord(null); record.setAlignmentStart(1000); diff --git a/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPileupTest.java b/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPileupTest.java index 76c587216..9c5fa8062 100644 --- a/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPileupTest.java +++ b/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPileupTest.java @@ -41,7 +41,7 @@ public void setUp() throws QBasePileupException, IOException { Options options = createMock(Options.class); expect(options.includeDuplicates()).andReturn(false); replay(options); - position = new IndelPosition(line, false, "pindel", cols); + position = new IndelPosition(line, false, cols); pileup = new IndelPileup(options, new InputBAM(testFolder.newFile("tumour.bam")), position, testFolder.newFile("reference.fa"), 13, 10, 3, true); record = new SAMRecord(null); record.setAlignmentStart(1000); @@ -216,18 +216,18 @@ public void testAddToNovelStarts() { public void testParseComplexIndel() { String line = "date\ttumour\tind6\t4\tchr1\t1007\t1012\t1\t-999\t-999\tG\t-999\tGTC\tG>GTC\t\t-999\t-999\t-999\t-999\t-999\t-999\t-999\t-999\tPASS\t--\t--\t--\t--"; - position = new IndelPosition(line, false, "pindel", cols); + position = new IndelPosition(line, false, cols); assertTrue(position.isComplex()); pileup.setIndelPosition(position); assertEquals(0, pileup.getInformativeReads()); assertEquals(0, pileup.getPartialIndelCount()); assertEquals(0, pileup.getNearbyIndelCount()); - pileup.parseComplexIndel(record, expectedMaskedBases); + pileup.parseComplexIndel(record); assertEquals(1, pileup.getInformativeReads()); assertEquals(1, pileup.getPartialIndelCount()); assertEquals(0, pileup.getNearbyIndelCount()); record.setCigarString("3M2D4M1I91M"); - pileup.parseComplexIndel(record, expectedMaskedBases); + pileup.parseComplexIndel(record); assertEquals(2, pileup.getInformativeReads()); assertEquals(2, pileup.getPartialIndelCount()); assertEquals(0, pileup.getNearbyIndelCount()); diff --git a/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPositionPileupTest.java b/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPositionPileupTest.java index d9cf05d6b..022fddf6a 100644 --- a/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPositionPileupTest.java +++ b/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPositionPileupTest.java @@ -43,8 +43,8 @@ public void setUp() throws QBasePileupException, IOException { File fref = testFolder.newFile("reference.fa"); String line = "date\ttumour\tind6\t2\tchr1\t3237948\t3237949\t1\t-999\t-999\tG\t-999\tGTC\tG/GTC\t\t-999\t-999\t-999\t-999\t-999\t-999\t-999\t-999\tPASS;\t--\t--\t--\t--"; - IndelPosition positionSomatic = new IndelPosition(line, false, "pindel", cols); - IndelPosition positionGermline = new IndelPosition(line, true, "pindel", cols); + IndelPosition positionSomatic = new IndelPosition(line, false, cols); + IndelPosition positionGermline = new IndelPosition(line, true, cols); Options optionS = createMockOptions(fref); Options optionG = createMockOptions(fref); IndexedFastaSequenceFile indexedFasta = createMockIndexedFasta(); diff --git a/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPositionTest.java b/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPositionTest.java index 4bce6800d..c2d994983 100644 --- a/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPositionTest.java +++ b/qbasepileup/test/org/qcmg/qbasepileup/indel/IndelPositionTest.java @@ -21,7 +21,7 @@ public void tearDown() { @Test public void testInsertion() { String line = "date\ttumour\tind6\t2\tchr1\t3237948\t3237949\t1\t-999\t-999\t-\t-999\tTC\t-/TC\t\t-999\t-999\t-999\t-999\t-999\t-999\t-999\t-999\tPASS\t--\t--\t--\t--"; - position = new IndelPosition(line, false, "pindel", cols); + position = new IndelPosition(line, false, cols); assertEquals("chr1", position.getChromosome()); assertEquals(3237948, position.getStart()); assertEquals(3237949, position.getEnd()); @@ -35,7 +35,7 @@ public void testInsertion() { @Test public void testDeletion() { String line = "date\ttumour\tind6\t3\tchr1\t3217897\t3217899\t1\t-999\t-999\tAAA\t-999\t---\tAAA/---\t\t-999\t-999\t-999\t-999\t-999\t-999\t-999\t-999\tPASS\t--\t--\t--\t--"; - position = new IndelPosition(line, false, "pindel", cols); + position = new IndelPosition(line, false, cols); assertEquals("chr1", position.getChromosome()); assertEquals(3217897, position.getStart()); assertEquals(3217899, position.getEnd()); @@ -50,7 +50,7 @@ public void testDeletion() { @Test public void testComplex() { String line = "date\ttumour\tind6\t4\tchr1\t3522121\t3522133\t1\t-999\t-999\tCTCATACACTCA\t-999\tCACGCT\tCTCATACACTCA>CACGCT\t\t-999\t-999\t-999 -999\t-999\t-999\t-999\t-999\tPASS\t--\t--\t--\t--"; - position = new IndelPosition(line, false, "pindel", cols); + position = new IndelPosition(line, false, cols); assertEquals("chr1", position.getChromosome()); assertEquals(3522121, position.getStart()); assertEquals(3522133, position.getEnd());