diff --git a/q3indel/src/au/edu/qimr/indel/Options.java b/q3indel/src/au/edu/qimr/indel/Options.java index 435f3a39c..4138b5743 100644 --- a/q3indel/src/au/edu/qimr/indel/Options.java +++ b/q3indel/src/au/edu/qimr/indel/Options.java @@ -109,9 +109,9 @@ public Options(final String[] args) throws IOException, Q3IndelException { controlVcf = getIOFromIni(iniFile, INI_SEC_IOS, "controlVcf"); } else if (runMode.equalsIgnoreCase(RUNMODE_DEFAULT)) { String[] inputs = iniFile.get(INI_SEC_IOS).getAll("inputVcf",String[].class); - for (int i = 0; i < inputs.length; i ++) { - pindelVcfs.add(new File(inputs[i])); - } + for (String input : inputs) { + pindelVcfs.add(new File(input)); + } } nearbyIndelWindow = Integer.parseInt( iniFile.fetch(INI_SEC_PARAM, "window.nearbyIndel")); @@ -140,7 +140,7 @@ private File getIOFromIni(Ini ini, String parent, String child) throws Q3IndelEx } String f = ini.fetch(parent, child); - if ( StringUtils.isNullOrEmpty(f) || f.toLowerCase().equals("null")) { + if ( StringUtils.isNullOrEmpty(f) || f.equalsIgnoreCase("null")) { return null; } @@ -236,14 +236,14 @@ public void detectBadOptions() throws Q3IndelException { throw new Q3IndelException("FILE_EXISTS_ERROR","(control gatk vcf) " + controlVcf.getAbsolutePath()); } } else if (RUNMODE_DEFAULT.equalsIgnoreCase(runMode)) { - if (pindelVcfs.size() == 0) { + if (pindelVcfs.isEmpty()) { throw new Q3IndelException("INPUT_OPTION_ERROR","(pindel input vcf) not specified" ); } - for (int i = 0; i < pindelVcfs.size(); i ++) { - if ( pindelVcfs.get(i) != null && ! pindelVcfs.get(i).exists()) { - throw new Q3IndelException("FILE_EXISTS_ERROR","(control indel vcf) " + pindelVcfs.get(i).getAbsolutePath()); - } - } + for (File pindelVcf : pindelVcfs) { + if (pindelVcf != null && !pindelVcf.exists()) { + throw new Q3IndelException("FILE_EXISTS_ERROR", "(control indel vcf) " + pindelVcf.getAbsolutePath()); + } + } } else { throw new Q3IndelException("UNKNOWN_RUNMODE_ERROR", runMode); } diff --git a/q3indel/src/au/edu/qimr/indel/pileup/IndelMT.java b/q3indel/src/au/edu/qimr/indel/pileup/IndelMT.java index 4a1c13a93..50aa3b59a 100644 --- a/q3indel/src/au/edu/qimr/indel/pileup/IndelMT.java +++ b/q3indel/src/au/edu/qimr/indel/pileup/IndelMT.java @@ -4,11 +4,7 @@ import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.AbstractQueue; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.CountDownLatch; @@ -157,17 +153,16 @@ public void run() { } } /** - * it swap SAMRecord between currentPool and nextPool. After then, the currentPool will contain all SAMRecord overlapping topPos position, - * the nextPool will contain all SAMRecord start after topPos position. All SAMRecord end before topPos position will be remvoved from both pool. + * it swap SAMRecord between currentPool and nextPool. After then, the currentPool will contain all SAMRecord overlapping topPos positions, + * the nextPool will contain all SAMRecord start after topPos position. All SAMRecord end before topPos position will be removed from both pools. * @param topPos pileup position - * @param currentPool a list of SAMRecord overlapped previous pileup Position + * @param currentPool a list of SAMRecord overlapped the previous pileup Position * @param nextPool a list of SAMRecord behind previous pileup Position */ void resetPool(IndelPosition topPos, List currentPool, List nextPool) { - List tmpCurrentPool = new ArrayList<>(); - List tmpPool = new ArrayList<>(); - tmpPool.addAll(nextPool); + List tmpCurrentPool = new ArrayList<>(); + List tmpPool = new ArrayList<>(nextPool); //check read record behind on current position for (SAMRecord re : tmpPool ) { @@ -237,14 +232,14 @@ public IndelMT(Options options, QLogger logger) throws IOException { } logger.info(indelload.getCountsNewIndel() + " indels are found from control vcf input."); logger.info(indelload.getCountsMultiIndel() + " indels are split from multi alleles in control vcf."); - logger.info(indelload.getCountsInputLine() + " variant records exsit inside control vcf input."); - logger.info(indelload.getCountsInputMultiAlt() + " variant records with multi alleles exsits inside control vcf input."); + logger.info(indelload.getCountsInputLine() + " variant records exist inside control vcf input."); + logger.info(indelload.getCountsInputMultiAlt() + " variant records with multi alleles exists inside control vcf input."); } //then test second column if (options.getTestInputVcf() != null) { indelload.appendTestIndels(options.getTestInputVcf()); - logger.info(indelload.getCountsInputLine() + " variant records exsit inside test vcf input."); - logger.info(indelload.getCountsInputMultiAlt() + " variants record with multi alleles exsits inside test vcf input."); + logger.info(indelload.getCountsInputLine() + " variant records exist inside test vcf input."); + logger.info(indelload.getCountsInputMultiAlt() + " variants record with multi alleles exists inside test vcf input."); logger.info(indelload.getCountsMultiIndel() + " indels are split from multi alleles inside test vcf"); logger.info(indelload.getCountsNewIndel() + " new indels are found in test vcf input only."); logger.info(indelload.getCountsOverlapIndel() + " indels are found in both control and test vcf inputs."); @@ -390,7 +385,7 @@ private void writeVCF(AbstractQueue tumourQueue, AbstractQueue getIndelList( SAMSequenceRecord contig) { - if (positionRecordMap == null || positionRecordMap.size() == 0) { + if (positionRecordMap == null || positionRecordMap.isEmpty()) { return new ConcurrentLinkedQueue<>(); } @@ -504,7 +499,7 @@ private AbstractQueue getIndelList( SAMSequenceRecord contig) { } //lambda expression to replace abstract method - list.sort( (IndelPosition o1, IndelPosition o2) -> o1.getChrRangePosition().compareTo( o2.getChrRangePosition()) ); + list.sort(Comparator.comparing(IndelPosition::getChrRangePosition)); return new ConcurrentLinkedQueue<>(list); } diff --git a/q3indel/src/au/edu/qimr/indel/pileup/IndelPileup.java b/q3indel/src/au/edu/qimr/indel/pileup/IndelPileup.java index a2b1438a8..ce653bfe7 100644 --- a/q3indel/src/au/edu/qimr/indel/pileup/IndelPileup.java +++ b/q3indel/src/au/edu/qimr/indel/pileup/IndelPileup.java @@ -113,7 +113,7 @@ private List getRegionIndels(List pool, int window) { for (CigarElement ce : cigar.getCigarElements()) { //insertion only one base, eg, start = 100; end = 101 if (CigarOperator.I == ce.getOperator()) { - //check whether it is supporting or partical indel + //check whether it is supporting or partial indel //if(refPos == indelStart ){ if (refPos >= indelStart && refPos <= indelEnd) { if (type.equals(SVTYPE.DEL) ) { @@ -122,7 +122,7 @@ private List getRegionIndels(List pool, int window) { support = true; // refPos==indelStart=indelEnd } } else if (refPos > windowStart && refPos < windowEnd) { - nearby = true; //nearby insertion overlap the window + nearby = true; //nearby insertion overlaps the window } } else if ( CigarOperator.D == ce.getOperator()) { //deletion overlaps variants, full/part supporting reads @@ -133,7 +133,7 @@ private List getRegionIndels(List pool, int window) { //indel chock have base on both side of indel region || (refPos <= indelStart && refPos + ce.getLength() - 1 >= indelEnd)) { if (type.equals(SVTYPE.INS)) { - nearby = true; //nearyby deletion + nearby = true; //nearby deletion } else { support = true; // supporting or partial } @@ -163,7 +163,7 @@ private List getRegionIndels(List pool, int window) { this.nearbyIndel = count; - // all nearby/faraway indle reads are removed + // all nearby/faraway indel reads are removed return regionPool; } @@ -191,7 +191,7 @@ private int[] getCounts(List pool, String motif) { Cigar cigar = re.getCigar(); for (CigarElement ce : cigar.getCigarElements()) { if (CigarOperator.I == ce.getOperator() && (refPos == indelEnd && type.equals(SVTYPE.INS))) { - //if insert rePos go next cigar block after cigar.I, which is indel end position + //if insert rePos go next cigar block after cigar. I, which is indel end position if (ce.getLength() != motif.length()) { partialflag = true; } else { diff --git a/q3indel/src/au/edu/qimr/indel/pileup/IndelPosition.java b/q3indel/src/au/edu/qimr/indel/pileup/IndelPosition.java index 21d2cb99c..bb3b88973 100644 --- a/q3indel/src/au/edu/qimr/indel/pileup/IndelPosition.java +++ b/q3indel/src/au/edu/qimr/indel/pileup/IndelPosition.java @@ -55,9 +55,9 @@ public IndelPosition(VcfRecord re, SVTYPE type) { position = new ChrRangePosition(fullChromosome, start, end); } - //next job: check all vcfs are same type, start and end + //next job: check all vcfs are the same type, start and end public IndelPosition(List res, SVTYPE type) { - this(res.get(0), type); + this(res.getFirst(), type); //append all vcfs vcfs.clear(); vcfs.addAll(res); @@ -154,21 +154,15 @@ public List getMotifs( ) { @Override public boolean equals(final Object o) { - if (!(o instanceof IndelPosition)) { + if (!(o instanceof IndelPosition other)) { return false; } - - final IndelPosition other = (IndelPosition) o; - - if (! this.mutationType .equals(other.mutationType)) { - return false; - } - - if ( ! this.position.equals(other.position)) { + + if (! this.mutationType .equals(other.mutationType)) { return false; } - - return true; + + return this.position.equals(other.position); } @Override @@ -203,14 +197,14 @@ public VcfRecord getPileupedVcf(int index, final int gematicNNS, final float gem return re; } - boolean somatic = (re.getFilter().equals(ReadIndels.FILTER_SOMATIC)) ? true : false; + boolean somatic = re.getFilter().equals(ReadIndels.FILTER_SOMATIC); if (normalPileup != null && somatic) { if ( normalPileup.getSupportReadCount(index) > gematicNNS ) { somatic = false; } else if (normalPileup.getInformativeCount() > 0) { int scount = normalPileup.getSupportReadCount(index); int icount = normalPileup.getInformativeCount(); - if ((100 * scount / icount) >= (gematicSOI * 100)) { + if (((float) (100 * scount) / icount) >= (gematicSOI * 100)) { somatic = false; } } @@ -285,7 +279,7 @@ public VcfRecord getPileupedVcf(int index, final int gematicNNS, final float gem //future job should check GT column //control always on first column and then test List field = new ArrayList<>(); - field.add( 0, (genotypeField.size() > 0) ? genotypeField.get(0) + ":" + IndelUtils.FORMAT_ACINDEL : IndelUtils.FORMAT_ACINDEL ); + field.add( 0, (!genotypeField.isEmpty()) ? genotypeField.get(0) + ":" + IndelUtils.FORMAT_ACINDEL : IndelUtils.FORMAT_ACINDEL ); field.add( 1, (genotypeField.size() > 1) ? genotypeField.get(1) + ":" + nd : nd); field.add( 2, (genotypeField.size() > 2) ? genotypeField.get(2) + ":" + td : td); re.setFormatFields( field ); diff --git a/q3indel/src/au/edu/qimr/indel/pileup/ReadIndels.java b/q3indel/src/au/edu/qimr/indel/pileup/ReadIndels.java index 73a8256ea..07005629f 100644 --- a/q3indel/src/au/edu/qimr/indel/pileup/ReadIndels.java +++ b/q3indel/src/au/edu/qimr/indel/pileup/ReadIndels.java @@ -27,10 +27,10 @@ public class ReadIndels { private VcfHeader header; private static final int errRecordLimit = 100; - //counts from each input, {No of new indel, No of overlap indel, No of indels with mult Allel, No of inputs variants, No of input variants with multi Allel} + //counts from each input, {No of new indel, No of overlap indel, No of indels with multi Allele, No of inputs variants, No of input variants with multi Allele} private final int[] counts = {0, 0, 0, 0, 0}; - //here key will be uniq for indel: chr, start, end, allel + //here key will be uniq for indel: chr, start, end, allele private final Map positionRecordMap = new ConcurrentHashMap<>(); public ReadIndels( QLogger logger) { @@ -49,7 +49,7 @@ public void appendTestIndels(File f) throws IOException { List format = vcf.getFormatFields(); if (format != null) { while (format.size() > 2) { - format.remove(format.size() - 1); + format.removeLast(); } vcf.setFormatFields(format); VcfUtils.addMissingDataToFormatFields(vcf, 2); @@ -94,12 +94,12 @@ private boolean mergeTestIndel(VcfRecord secVcf) { //only keep first sample column of second vcf List secformat = secVcf.getFormatFields(); while (secformat != null && secformat.size() > 2 ) { - secformat.remove(secformat.size() - 1); + secformat.removeLast(); } //copy secVcf with sample column "FORMAT oriSample" only if (existingvcf == null) { - //the test only indel always set as somatic, even gatkeTest runMode + //the test only indel always set as somatic, even gatk Test runMode existingvcf = new VcfRecord.Builder(secVcf.getChrPosition(), secVcf.getRef()) .id(secVcf.getId()).allele(secVcf.getAlt()).filter(FILTER_SOMATIC).build(); @@ -116,15 +116,15 @@ private boolean mergeTestIndel(VcfRecord secVcf) { return false; } else { //gatk mode already set filter as "." (germline) ignore pileup, since they are also appear on control vcf - //only keep first sample column of exsiting vcf + //only keep first sample column of existing vcf List format1 = existingvcf.getFormatFields(); if (format1 != null) { while (format1.size() > 2 ) { - format1.remove(format1.size() - 1); + format1.removeLast(); } existingvcf.setFormatFields(format1); - //merge exiting and second vcf format, the exsitingvcf already inside map + //merge exiting and second vcf format, the existing vcf already inside map VcfUtils.addAdditionalSampleToFormatField(existingvcf, secformat) ; } return true; @@ -178,7 +178,7 @@ public void loadIndels(File f) throws IOException { vcf1.setFilter(Constants.MISSING_DATA_STRING); if (positionRecordMap.containsKey(vcf1) && (indelOverlap ++) < errRecordLimit) { - logger.warn("same variants already exsits, this one will be discard:\n" + positionRecordMap.get(vcf1).toString() ); + logger.warn("same variants already exists, this one will be discard:\n" + positionRecordMap.get(vcf1).toString() ); continue; //no overwrite but just warning } positionRecordMap.put(vcf1, vcf1); @@ -197,7 +197,7 @@ public void loadIndels(File f) throws IOException { } /** - * change the input vcf by putting '.' on "GT" field if there are multi Alleles existis; + * change the input vcf by putting '.' on "GT" field if multi Alleles exists; * do nothing if not multi Alleles or not GT field on format column * @param vcf input vcf record */ @@ -211,7 +211,7 @@ public void resetGenotype(VcfRecord vcf) { //add GD to second field VcfFormatFieldRecord[] frecords = new VcfFormatFieldRecord[format.size() - 1]; for (int i = 1; i < format.size(); i ++) { - VcfFormatFieldRecord re = new VcfFormatFieldRecord(format.get(0), format.get(i)); + VcfFormatFieldRecord re = new VcfFormatFieldRecord(format.getFirst(), format.get(i)); String gd = IndelUtils.getGenotypeDetails(re, vcf.getRef(), vcf.getAlt() ); re.setField(1, VcfHeaderUtils.FORMAT_GENOTYPE_DETAILS, gd == null ? Constants.MISSING_DATA_STRING : gd); @@ -229,7 +229,7 @@ public void resetGenotype(VcfRecord vcf) { for (int i = 1; i < frecords.length; i++) { //the exception shouldn't happen if ( !frecords[i].getFormatColumnString().equals(frecords[0].getFormatColumnString())) { - throw new IllegalArgumentException("both sample column with differnt format column: \n" + throw new IllegalArgumentException("both sample column with different format column: \n" + frecords[0].getFormatColumnString() + "\n" + frecords[i].getFormatColumnString()); } format.add(frecords[i].getSampleColumnString()); @@ -241,7 +241,6 @@ public void resetGenotype(VcfRecord vcf) { /** * * @return a map of, key is the indel position, value is the list a vcf record on that position. - * @throws Exception */ public Map getIndelMap() throws Q3IndelException { diff --git a/q3indel/test/au/edu/qimr/indel/IniFileTest.java b/q3indel/test/au/edu/qimr/indel/IniFileTest.java index 6a89ea7a9..8eebe8080 100644 --- a/q3indel/test/au/edu/qimr/indel/IniFileTest.java +++ b/q3indel/test/au/edu/qimr/indel/IniFileTest.java @@ -38,9 +38,7 @@ public void setup() throws IOException { @Test public void testQuery() throws IOException, Q3IndelException { - - - + //ini file not exist String[] args = {"-i", fini.getAbsolutePath()}; try { @@ -51,33 +49,33 @@ public void testQuery() throws IOException, Q3IndelException { // create ini file without query and some dodgy file createIniFile(fini,fini,fini,fini,fini, null, blah); - Options options = new Options(args); - assertTrue(options.getFilterQuery() == null); + Options options = new Options(args); + assertNull(options.getFilterQuery()); // create ini file with empty query createIniFile(fini,fini,fini,fini,fini, "", blah); - options = new Options(args); - assertTrue(options.getFilterQuery() == null); + options = new Options(args); + assertNull(options.getFilterQuery()); } @Test public final void testIni() { - // create ini file with query + // create ini file with query String str = "and (flag_ReadUnmapped != true, flag_DuplicatedRead != true)"; createIniFile(fini,fini,fini,fini,fini, str,output); try { Options options = new Options(new String[]{"-i", fini.getAbsolutePath()}); assertTrue(options.getFilterQuery().equalsIgnoreCase(str)); - assertTrue(options.getControlBam().getAbsolutePath().equals(fini.getAbsolutePath() )); - assertTrue(options.getTestBam().getAbsolutePath().equals(fini.getAbsolutePath())); - assertTrue(options.getControlInputVcf().getAbsolutePath().equals(fini.getAbsolutePath())); - assertTrue(options.getTestInputVcf().getAbsolutePath().equals(fini.getAbsolutePath())); + assertEquals(options.getControlBam().getAbsolutePath(), fini.getAbsolutePath()); + assertEquals(options.getTestBam().getAbsolutePath(), fini.getAbsolutePath()); + assertEquals(options.getControlInputVcf().getAbsolutePath(), fini.getAbsolutePath()); + assertEquals(options.getTestInputVcf().getAbsolutePath(), fini.getAbsolutePath()); assertEquals("OESO-5007", options.getDonorId()); - - assertTrue(options.getControlSample().equals("Normalcontrol(othersite):a6b558da-ab2d-4e92-a029-6544fb98653b")); - assertTrue(options.getTestSample().equals("Primarytumour:4ca050b3-d15b-436b-b035-d6c1925b59fb")); + + assertEquals("Normalcontrol(othersite):a6b558da-ab2d-4e92-a029-6544fb98653b", options.getControlSample()); + assertEquals("Primarytumour:4ca050b3-d15b-436b-b035-d6c1925b59fb", options.getTestSample()); } catch (Exception e) { Assert.fail("Should not threw a Exception"); } @@ -119,8 +117,8 @@ public static void createIniFile(File ini, File testbam, File controlbam, File t for (String line : data) out.write(line + "\n"); }catch(IOException e){ - System.err.println( Q3IndelException.getStrackTrace(e)); - assertTrue(false); + System.err.println( Q3IndelException.getStrackTrace(e)); + fail(); } } diff --git a/q3indel/test/au/edu/qimr/indel/Support.java b/q3indel/test/au/edu/qimr/indel/Support.java index 1be57c9b6..427e197a5 100644 --- a/q3indel/test/au/edu/qimr/indel/Support.java +++ b/q3indel/test/au/edu/qimr/indel/Support.java @@ -1,6 +1,7 @@ package au.edu.qimr.indel; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import htsjdk.samtools.SAMFileWriter; import htsjdk.samtools.SAMRecord; import htsjdk.samtools.SamReader; @@ -34,13 +35,13 @@ public static void createBam( List data1, File output) throws IOExceptio try( BufferedWriter out = new BufferedWriter(new FileWriter(tmp))) { for (String line : data) out.write(line + "\n"); }catch(IOException e){ - System.err.println( Q3IndelException.getStrackTrace(e)); - assertTrue(false); + System.err.println( Q3IndelException.getStrackTrace(e)); + fail(); } - try(SamReader reader = SAMFileReaderFactory.createSAMFileReader(tmp);){ + try(SamReader reader = SAMFileReaderFactory.createSAMFileReader(tmp)){ SAMWriterFactory factory = new SAMWriterFactory(reader.getFileHeader() ,false, output); - try(SAMFileWriter writer = factory.getWriter();) { + try(SAMFileWriter writer = factory.getWriter()) { for( SAMRecord record : reader) writer.addAlignment(record); } factory.renameIndex(); //try already closed writer diff --git a/q3indel/test/au/edu/qimr/indel/pileup/ContigPileupTest.java b/q3indel/test/au/edu/qimr/indel/pileup/ContigPileupTest.java index f37fae498..e6633e6d3 100644 --- a/q3indel/test/au/edu/qimr/indel/pileup/ContigPileupTest.java +++ b/q3indel/test/au/edu/qimr/indel/pileup/ContigPileupTest.java @@ -1,6 +1,5 @@ package au.edu.qimr.indel.pileup; -import static org.junit.Assert.assertTrue; import htsjdk.samtools.SAMRecord; import htsjdk.samtools.SamReader; @@ -19,6 +18,8 @@ import au.edu.qimr.indel.Q3IndelException; import au.edu.qimr.indel.pileup.IndelMT.ContigPileup; +import static org.junit.Assert.*; + public class ContigPileupTest { @org.junit.Rule public TemporaryFolder testFolder = new TemporaryFolder(); @@ -29,8 +30,8 @@ public void resetPoolTest() throws IOException{ createSam(inputBam); //get pool - List pool = new ArrayList(); - List nextpool = new ArrayList(); + List pool = new ArrayList<>(); + List nextpool = new ArrayList<>(); SamReader inreader = SAMFileReaderFactory.createSAMFileReader( inputBam); VcfRecord vcf = new VcfRecord(new String[] {"chr11", "500", null, "TAAAAAGGGGGTTTTTCCCCC", "T" }); @@ -46,73 +47,70 @@ public void resetPoolTest() throws IOException{ inreader.close(); //before resetPool - assertTrue(pool.size() == IndelMT.MAXRAMREADS + 20); - assertTrue(nextpool.size() == 1); + assertEquals(IndelMT.MAXRAMREADS + 20, pool.size()); + assertEquals(1, nextpool.size()); //reset for first indel IndelMT mt = new IndelMT(); ContigPileup pileup = mt.new ContigPileup(); pileup.resetPool(topPos, pool, nextpool); - assertTrue(pool.size() == IndelMT.MAXRAMREADS + 20); - assertTrue(nextpool.size() == 1); + assertEquals(IndelMT.MAXRAMREADS + 20, pool.size()); + assertEquals(1, nextpool.size()); vcf = new VcfRecord(new String[] {"chr11", "510", null, "TAAAAAGGGGGTTTTTCCCCC", "T" }); topPos = new IndelPosition(vcf); pileup.resetPool(topPos, pool, nextpool); - assertTrue(pool.size() == IndelMT.MAXRAMREADS + 20); - assertTrue(nextpool.size() == 1); + assertEquals(IndelMT.MAXRAMREADS + 20, pool.size()); + assertEquals(1, nextpool.size()); //deletion just start one base after first input read vcf = new VcfRecord(new String[] {"chr11", "551", null, "TAAAAAGGGGGTTTTTCCCCC", "T" }); topPos = new IndelPosition(vcf); pileup.resetPool(topPos, pool, nextpool); - assertTrue(pool.size() == 10); - assertTrue(nextpool.size() == 1); + assertEquals(10, pool.size()); + assertEquals(1, nextpool.size()); vcf = new VcfRecord(new String[] {"chr11", "561", null, "TAAAAAGGGGGTTTTTCCCCC", "T" }); topPos = new IndelPosition(vcf); pileup.resetPool(topPos, pool, nextpool); - assertTrue(pool.size() == 0); - assertTrue(nextpool.size() == 1); + assertEquals(0, pool.size()); + assertEquals(1, nextpool.size()); } - public static void createSam(File inputBam){ - List data = new ArrayList(); - data.add("@HD VN:1.0 SO:coordinate"); - data.add("@RG ID:20140717025441134 SM:eBeads_20091110_CD DS:rl=50"); - data.add("@PG ID:qtest::Test VN:0.2pre"); - data.add("@SQ SN:chrY LN:249250621"); - data.add("@SQ SN:chr11 LN:243199373"); - data.add("@CO create by qcmg.qbamfilter.filter::TestFile"); - - for(int i = 0; i < IndelMT.MAXRAMREADS + 10; i ++ ) - data.add(i+"997_1173_1256 99 chr11 401 60 100M20D31M = 600 351 " + - "TATGTTTTTTAGTAGAGACAGGGTCTCACTGTGTTGCCCAGGCTAGTCTCTAACTCCTGGGCTCAAATTATCCTCCCCACTTGGCCTCCCAAAAGGATTGGATTACAGGCATAAGCCACTGCCCCAAGCCC " + - "FFFFFFJFJJJJFJJFJFJJFAJJJJJJJJJJFJJJJJJJFJJJJJJJFJFJJJJJJJJJFJAJJJJJJJJJJJJJJJJFJFJJJJFJJJFFFJJJJAFFJFJJJJJFJFJFJJJFJJJFFJJJAFFJJJJ "+ - "MD:Z:112^A39 PG:Z:MarkDuplicates.5 RG:Z:20140717025441134"); - - for(int i = 0; i < 10; i ++ ) - data.add(i+"997_1173_1257 99 chr11 411 60 100M20D31M = 610 351 " + - "TATGTTTTTTAGTAGAGACAGGGTCTCACTGTGTTGCCCAGGCTAGTCTCTAACTCCTGGGCTCAAATTATCCTCCCCACTTGGCCTCCCAAAAGGATTGGATTACAGGCATAAGCCACTGCCCCAAGCCC " + - "FFFFFFJFJJJJFJJFJFJJFAJJJJJJJJJJFJJJJJJJFJJJJJJJFJFJJJJJJJJJFJAJJJJJJJJJJJJJJJJFJFJJJJFJJJFFFJJJJAFFJFJJJJJFJFJFJJJFJJJFFJJJAFFJJJJ " + - "RG:Z:20140717025441134"); - - data.add("1997_1173_1258 99 chr11 611 60 100M20D31M = 800 351 " + - "TATGTTTTTTAGTAGAGACAGGGTCTCACTGTGTTGCCCAGGCTAGTCTCTAACTCCTGGGCTCAAATTATCCTCCCCACTTGGCCTCCCAAAAGGATTGGATTACAGGCATAAGCCACTGCCCCAAGCCC " + - "FFFFFFJFJJJJFJJFJFJJFAJJJJJJJJJJFJJJJJJJFJJJJJJJFJFJJJJJJJJJFJAJJJJJJJJJJJJJJJJFJFJJJJFJJJFFFJJJJAFFJFJJJJJFJFJFJJJFJJJFFJJJAFFJJJJ " + - "RG:Z:20140717025441134"); - - - try( BufferedWriter out = new BufferedWriter(new FileWriter(inputBam ))) { - for (String line : data) - out.write(line + "\n"); - }catch(IOException e){ - System.err.println( Q3IndelException.getStrackTrace(e)); - assertTrue(false); - } - - - } - + public static void createSam(File inputBam){ + List data = new ArrayList(); + data.add("@HD VN:1.0 SO:coordinate"); + data.add("@RG ID:20140717025441134 SM:eBeads_20091110_CD DS:rl=50"); + data.add("@PG ID:qtest::Test VN:0.2pre"); + data.add("@SQ SN:chrY LN:249250621"); + data.add("@SQ SN:chr11 LN:243199373"); + data.add("@CO create by qcmg.qbamfilter.filter::TestFile"); + + for(int i = 0; i < IndelMT.MAXRAMREADS + 10; i ++ ) { + data.add(i + "997_1173_1256 99 chr11 401 60 100M20D31M = 600 351 " + + "TATGTTTTTTAGTAGAGACAGGGTCTCACTGTGTTGCCCAGGCTAGTCTCTAACTCCTGGGCTCAAATTATCCTCCCCACTTGGCCTCCCAAAAGGATTGGATTACAGGCATAAGCCACTGCCCCAAGCCC " + + "FFFFFFJFJJJJFJJFJFJJFAJJJJJJJJJJFJJJJJJJFJJJJJJJFJFJJJJJJJJJFJAJJJJJJJJJJJJJJJJFJFJJJJFJJJFFFJJJJAFFJFJJJJJFJFJFJJJFJJJFFJJJAFFJJJJ " + + "MD:Z:112^A39 PG:Z:MarkDuplicates.5 RG:Z:20140717025441134"); + } + for(int i = 0; i < 10; i ++ ) { + data.add(i + "997_1173_1257 99 chr11 411 60 100M20D31M = 610 351 " + + "TATGTTTTTTAGTAGAGACAGGGTCTCACTGTGTTGCCCAGGCTAGTCTCTAACTCCTGGGCTCAAATTATCCTCCCCACTTGGCCTCCCAAAAGGATTGGATTACAGGCATAAGCCACTGCCCCAAGCCC " + + "FFFFFFJFJJJJFJJFJFJJFAJJJJJJJJJJFJJJJJJJFJJJJJJJFJFJJJJJJJJJFJAJJJJJJJJJJJJJJJJFJFJJJJFJJJFFFJJJJAFFJFJJJJJFJFJFJJJFJJJFFJJJAFFJJJJ " + + "RG:Z:20140717025441134"); + } + data.add("1997_1173_1258 99 chr11 611 60 100M20D31M = 800 351 " + + "TATGTTTTTTAGTAGAGACAGGGTCTCACTGTGTTGCCCAGGCTAGTCTCTAACTCCTGGGCTCAAATTATCCTCCCCACTTGGCCTCCCAAAAGGATTGGATTACAGGCATAAGCCACTGCCCCAAGCCC " + + "FFFFFFJFJJJJFJJFJFJJFAJJJJJJJJJJFJJJJJJJFJJJJJJJFJFJJJJJJJJJFJAJJJJJJJJJJJJJJJJFJFJJJJFJJJFFFJJJJAFFJFJJJJJFJFJFJJJFJJJFFJJJAFFJJJJ " + + "RG:Z:20140717025441134"); + + + try( BufferedWriter out = new BufferedWriter(new FileWriter(inputBam ))) { + for (String line : data) + out.write(line + "\n"); + }catch(IOException e){ + System.err.println( Q3IndelException.getStrackTrace(e)); + fail(); + } + } } diff --git a/q3indel/test/au/edu/qimr/indel/pileup/IndelMTTest.java b/q3indel/test/au/edu/qimr/indel/pileup/IndelMTTest.java index cd05dbaeb..aaee3053f 100644 --- a/q3indel/test/au/edu/qimr/indel/pileup/IndelMTTest.java +++ b/q3indel/test/au/edu/qimr/indel/pileup/IndelMTTest.java @@ -7,10 +7,8 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; + +import org.junit.*; import org.junit.rules.TemporaryFolder; import org.qcmg.common.util.IndelUtils; import org.qcmg.common.vcf.VcfRecord; @@ -71,8 +69,8 @@ record = re; assertTrue(record.getFilter().contains("NNS")); if(record.getChromosome().equals("chrY")){ //input 12 reads including one duplicate so coverage is 11 - assertTrue(record.getSampleFormatRecord(1).getField("ACINDEL").equals("2,12,11,3[1,2],4[3],2,4,4")); - assertTrue(record.getFilter().equals("NNS")); + assertEquals("2,12,11,3[1,2],4[3],2,4,4", record.getSampleFormatRecord(1).getField("ACINDEL")); + assertEquals("NNS", record.getFilter()); }else{ assertTrue(record.getFilter().contains("COVN8")); assertTrue(record.getFilter().contains("COVT")); @@ -89,7 +87,8 @@ record = re; public void withQueryTest() throws IOException{ Options options = Support.runQ3IndelNoHom( ini_query.getAbsolutePath()); - assertTrue(options.getFilterQuery().equals(query)); + Assert.assertNotNull(options); + assertEquals(query, options.getFilterQuery()); //check output int passNo = 0; VcfRecord record = null; @@ -109,23 +108,24 @@ else if(passNo == 3) } } //there is no record pass the query so no indel counts - assertTrue(passNo == 4); - if(record.getChromosome().equals("chrY")){ - assertTrue(record.getSampleFormatRecord(1).getField(IndelUtils.FORMAT_ACINDEL).equals(".")); - assertTrue(record.getSampleFormatRecord(2).getField(IndelUtils.FORMAT_ACINDEL).equals(".")); + assertEquals(4, passNo); + Assert.assertNotNull(record); + if(record.getChromosome().equals("chrY")){ + assertEquals(".", record.getSampleFormatRecord(1).getField(IndelUtils.FORMAT_ACINDEL)); + assertEquals(".", record.getSampleFormatRecord(2).getField(IndelUtils.FORMAT_ACINDEL)); } //check sample column name - assertTrue(header.getSampleId()[0].equals( test_bam.getName().replaceAll("(?i).bam", "") )); - assertTrue(header.getSampleId()[1].equals( test_bam.getName().replaceAll("(?i).bam", "") )); - assertTrue( header.firstMatchedRecord(VcfHeaderUtils.STANDARD_DONOR_ID).getMetaValue().equals(options.getDonorId()) ); - assertTrue( header.firstMatchedRecord(VcfHeaderUtils.STANDARD_CONTROL_SAMPLE).getMetaValue().equals(options.getControlSample()) ); - assertTrue( header.firstMatchedRecord(VcfHeaderUtils.STANDARD_TEST_SAMPLE).getMetaValue().equals(options.getTestSample()) ); - assertTrue( header.firstMatchedRecord(VcfHeaderUtils.STANDARD_INPUT_LINE + "_GATK_TEST").getMetaValue().equals(options.getTestInputVcf().getAbsolutePath()) ); - assertTrue( header.firstMatchedRecord(VcfHeaderUtils.STANDARD_INPUT_LINE + "_GATK_CONTROL").getMetaValue().equals(options.getControlInputVcf().getAbsolutePath()) ); - assertTrue( header.firstMatchedRecord(VcfHeaderUtils.STANDARD_CONTROL_BAM ).getMetaValue().equals(options.getControlBam().getAbsolutePath()) ); - assertTrue( header.firstMatchedRecord(VcfHeaderUtils.STANDARD_TEST_BAM ).getMetaValue().equals(options.getTestBam().getAbsolutePath()) ); - assertTrue( header.firstMatchedRecord(VcfHeaderUtils.STANDARD_ANALYSIS_ID).getMetaValue().equals(options.getAnalysisId()) ); + assertEquals(header.getSampleId()[0], test_bam.getName().replaceAll("(?i).bam", "")); + assertEquals(header.getSampleId()[1], test_bam.getName().replaceAll("(?i).bam", "")); + assertEquals(header.firstMatchedRecord(VcfHeaderUtils.STANDARD_DONOR_ID).getMetaValue(), options.getDonorId()); + assertEquals(header.firstMatchedRecord(VcfHeaderUtils.STANDARD_CONTROL_SAMPLE).getMetaValue(), options.getControlSample()); + assertEquals(header.firstMatchedRecord(VcfHeaderUtils.STANDARD_TEST_SAMPLE).getMetaValue(), options.getTestSample()); + assertEquals(header.firstMatchedRecord(VcfHeaderUtils.STANDARD_INPUT_LINE + "_GATK_TEST").getMetaValue(), options.getTestInputVcf().getAbsolutePath()); + assertEquals(header.firstMatchedRecord(VcfHeaderUtils.STANDARD_INPUT_LINE + "_GATK_CONTROL").getMetaValue(), options.getControlInputVcf().getAbsolutePath()); + assertEquals(header.firstMatchedRecord(VcfHeaderUtils.STANDARD_CONTROL_BAM).getMetaValue(), options.getControlBam().getAbsolutePath()); + assertEquals(header.firstMatchedRecord(VcfHeaderUtils.STANDARD_TEST_BAM).getMetaValue(), options.getTestBam().getAbsolutePath()); + assertEquals(header.firstMatchedRecord(VcfHeaderUtils.STANDARD_ANALYSIS_ID).getMetaValue(), options.getAnalysisId()); } public static void createDelBam( File output) throws IOException { diff --git a/q3indel/test/au/edu/qimr/indel/pileup/IndelPileupTest.java b/q3indel/test/au/edu/qimr/indel/pileup/IndelPileupTest.java index 14d17c591..523bbbe1b 100644 --- a/q3indel/test/au/edu/qimr/indel/pileup/IndelPileupTest.java +++ b/q3indel/test/au/edu/qimr/indel/pileup/IndelPileupTest.java @@ -5,7 +5,6 @@ import htsjdk.samtools.SAMFileHeader; import htsjdk.samtools.SAMRecord; -import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -21,7 +20,7 @@ public class IndelPileupTest { QLogger logger = QLoggerFactory.getLogger(IndelPileupTest.class); @Test - public void insertTest() throws Exception{ + public void insertTest() { //pileup List vcfs = new ArrayList<>(); vcfs.add(new VcfRecord.Builder("chr1", 183014, "G").allele("GTT").build()); @@ -33,27 +32,27 @@ public void insertTest() throws Exception{ pileup.pileup(pool); //assert first insertion vcf - assertTrue(pileup.getInformativeCount() == 3); - assertTrue(pileup.getSupportReadCount(0) == 1); - assertTrue(pileup.getPartialReadCount(0) == 1); - assertTrue(pileup.getSupportNovelStartReadCount(0) == 1); + assertEquals(3, pileup.getInformativeCount()); + assertEquals(1, pileup.getSupportReadCount(0)); + assertEquals(1, pileup.getPartialReadCount(0)); + assertEquals(1, pileup.getSupportNovelStartReadCount(0)); // 4 events supporting reads (one INS three snps) won't count as strong supporting - assertTrue(pileup.getStrongSupportReadCount(0) == 0); + assertEquals(0, pileup.getStrongSupportReadCount(0)); //novelStrats for strong supporting - assertTrue(pileup.getStrongSupportNovelStartReadCount(0) == 0); + assertEquals(0, pileup.getStrongSupportNovelStartReadCount(0)); //assert second insertion vcf - assertTrue(pileup.getInformativeCount() == 3); - assertTrue(pileup.getSupportReadCount(1) == 1); - assertTrue(pileup.getSupportNovelStartReadCount(1) == 1); - assertTrue(pileup.getPartialReadCount(1) == 1); - //MD:Z:23G38T0C57 adjacant snps count as one, so one snp, one mnp and one INS, total 3 events + assertEquals(3, pileup.getInformativeCount()); + assertEquals(1, pileup.getSupportReadCount(1)); + assertEquals(1, pileup.getSupportNovelStartReadCount(1)); + assertEquals(1, pileup.getPartialReadCount(1)); + //MD:Z:23G38T0C57 adjacent snps count as one, so one snp, one mnp and one INS, total 3 events assertEquals(1, pileup.getStrongSupportReadCount(1)); - assertTrue(pileup.getStrongSupportNovelStartReadCount(1) == 1); + assertEquals(1, pileup.getStrongSupportNovelStartReadCount(1)); } @Test - public void deleteTest() throws Exception{ + public void deleteTest() { //get delete indel VcfRecord vs = new VcfRecord.Builder("chr1", 197, "CAG").allele("C").build(); IndelPosition indel = new IndelPosition (vs); @@ -61,20 +60,20 @@ public void deleteTest() throws Exception{ List pool = makePool(indel.getEnd()); IndelPileup pileup = new IndelPileup( indel, 13, 3,3); pileup.pileup(pool); - - assertTrue(pileup.getmotif(0).equals("AG")); - assertTrue(pileup.getInformativeCount() == 2); - assertTrue(pileup.getSupportReadCount(0) == 2); - assertTrue(pileup.getPartialReadCount(0) == 0); + + assertEquals("AG", pileup.getmotif(0)); + assertEquals(2, pileup.getInformativeCount()); + assertEquals(2, pileup.getSupportReadCount(0)); + assertEquals(0, pileup.getPartialReadCount(0)); // 3 events: cigar 130M1I3M2D17M and MD:Z:11G0T121^AG17 //8 events: cigar 131M2D20M and MD:Z:47A1G1A1C2C1G1C70^AG20 - assertTrue(pileup.getStrongSupportReadCount(0) == 1); - assertTrue(pileup.getSupportNovelStartReadCount(0) == 2); - assertTrue(pileup.getStrongSupportNovelStartReadCount(0) == 1); + assertEquals(1, pileup.getStrongSupportReadCount(0)); + assertEquals(2, pileup.getSupportNovelStartReadCount(0)); + assertEquals(1, pileup.getStrongSupportNovelStartReadCount(0)); } @Test - public void nearbySoftTest() throws Exception{ + public void nearbySoftTest() { VcfRecord vs = new VcfRecord.Builder("chrX", 150936181, "GTGTGT").allele("G").build(); IndelPosition indel = new IndelPosition (vs); @@ -82,7 +81,7 @@ public void nearbySoftTest() throws Exception{ List pool = new ArrayList<>(); pool.add(new SAMRecord(null )); - SAMRecord record = pool.get(0); + SAMRecord record = pool.getFirst(); //no soft clip, even hord clip inside window record.setReferenceName("chrX"); @@ -90,23 +89,23 @@ public void nearbySoftTest() throws Exception{ record.setReadString("AAAAAAAAATTTTTTTTTTGGGGGGGGGGCCCCCCCCCCAAAAAAAAAA"); record.setCigarString("96H45M9H"); record.setFlags(2227); - pileup.pileup(pool); - assertTrue(pileup.getNearybySoftclipCount() == 0); + pileup.pileup(pool); + assertEquals(0, pileup.getNearybySoftclipCount()); //right soft clip inside window record.setCigarString("96H45M9S"); pileup.pileup(pool); - assertTrue(pileup.getNearybySoftclipCount() == 1); + assertEquals(1, pileup.getNearybySoftclipCount()); //both side of soft clip are inside window record.setAlignmentStart(150936172); record.setCigarString("96S4M9S"); pileup.pileup(pool); - assertTrue(pileup.getNearybySoftclipCount() == 1); + assertEquals(1, pileup.getNearybySoftclipCount()); } @Test - public void bigDelTest() throws Exception{ + public void bigDelTest() { VcfRecord vs = new VcfRecord.Builder("chrX", 150936181, "GTGTGTTTTTTTTTTTTTTTTTTTTTTTTTTTTT").allele("G").build(); IndelPosition indel = new IndelPosition (vs); @@ -114,7 +113,7 @@ public void bigDelTest() throws Exception{ List pool = new ArrayList<>(); pool.add(new SAMRecord(null )); - SAMRecord record = pool.get(0); + SAMRecord record = pool.getFirst(); //two deletion happen inside indel region record.setReferenceName("chrX"); @@ -123,13 +122,13 @@ public void bigDelTest() throws Exception{ record.setCigarString("26M5D2M1D22M"); record.setFlags(2227); - pileup.pileup(pool); - assertTrue(pileup.getNearbyIndelCount() == 0); - assertTrue(pileup.getSupportReadCount(0) == 0); - assertTrue(pileup.getPartialReadCount(0) == 1); + pileup.pileup(pool); + assertEquals(0, pileup.getNearbyIndelCount()); + assertEquals(0, pileup.getSupportReadCount(0)); + assertEquals(1, pileup.getPartialReadCount(0)); } - private List makePool(int indelEnd) throws IOException{ + private List makePool(int indelEnd) { List pool = new ArrayList<>(); pool.add(createSamRec("1997_1173_1256 99 chr1 183011 60 112M1D39M = 183351 491 " + diff --git a/q3indel/test/au/edu/qimr/indel/pileup/IndelPositionTest.java b/q3indel/test/au/edu/qimr/indel/pileup/IndelPositionTest.java index 3e2db4e5a..4ddda9dc1 100644 --- a/q3indel/test/au/edu/qimr/indel/pileup/IndelPositionTest.java +++ b/q3indel/test/au/edu/qimr/indel/pileup/IndelPositionTest.java @@ -1,9 +1,6 @@ package au.edu.qimr.indel.pileup; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -23,6 +20,8 @@ import au.edu.qimr.indel.Support; import au.edu.qimr.indel.IniFileTest; +import static org.junit.Assert.*; + public class IndelPositionTest { @Rule @@ -60,7 +59,7 @@ public void createInput() throws IOException { //dodgy fake reference and index ContigPileupTest.createSam(new File(inputIndel + ".fai")); - List data = new ArrayList(); + List data = new ArrayList<>(); data.add(VcfHeaderUtils.STANDARD_FINAL_HEADER_LINE); Support.createVcf(data,data, emptyVcf); //empty vcf; } @@ -69,7 +68,7 @@ public void createInput() throws IOException { //test HCOVN and HCOVT can't have other flag or SOMATIC public void HCOVTest() throws Exception{ - List data = new ArrayList(); + List data = new ArrayList<>(); for(int i = 1; i <= 1000; i ++) data.add("ST-" + i + ":a:102\t99\tchrY\t2672601\t60\t10M2D123M2D10M8S\t=\t2673085\t631\tGTAGTTTATATTTCTGTGGGGTCAGTGGTGATATCCCTTTTATTATTTTTTATTGTGTCTTTTTGATTCTTCTCTCTTTTCTTTTTTATTAATCTACCTAGCAGTCTATCTTATTGGGTGTG\t*"); Support.createBam(data, tumourBAM); @@ -84,8 +83,8 @@ public void HCOVTest() throws Exception{ try (VcfFileReader reader = new VcfFileReader(output)) { for (VcfRecord re : reader) if(re.getChromosome().equals("chrY")){ - assertTrue(re.getFilter().equals(IndelUtils.FILTER_HCOVN)); - assertTrue(re.getSampleFormatRecord(2).getField("ACINDEL") == null ); + assertEquals(IndelUtils.FILTER_HCOVN, re.getFilter()); + assertNull(re.getSampleFormatRecord(2).getField("ACINDEL")); } } @@ -97,9 +96,9 @@ public void HCOVTest() throws Exception{ try (VcfFileReader reader = new VcfFileReader(output)) { for (VcfRecord re : reader) if(re.getChromosome().equals("chrY")){ - assertTrue(!re.getFilter().equals(IndelUtils.FILTER_HCOVN)); - assertTrue(re.getFilter().equals(IndelUtils.FILTER_HCOVT)); - assertTrue(re.getSampleFormatRecord(1).getField("ACINDEL") == null ); + assertNotEquals(IndelUtils.FILTER_HCOVN, re.getFilter()); + assertEquals(IndelUtils.FILTER_HCOVT, re.getFilter()); + assertNull(re.getSampleFormatRecord(1).getField("ACINDEL")); } } @@ -109,7 +108,7 @@ public void HCOVTest() throws Exception{ //ACINDEL==1,7,7,7[7,0],7[1],0,0,7 novel start of support read in normal is 7 public void germlineTest1() throws IOException{ //normal BAM with one novel start - List data = new ArrayList(); + List data = new ArrayList<>(); for(int i = 1; i <= 7; i ++) data.add("ST-" + i + ":a:102\t99\tchrY\t2672601\t60\t10M2D123M2D10M8S\t=\t2673085\t631\tGTAGTTTATATTTCTGTGGGGTCAGTGGTGATATCCCTTTTATTATTTTTTATTGTGTCTTTTTGATTCTTCTCTCTTTTCTTTTTTATTAATCTACCTAGCAGTCTATCTTATTGGGTGTG\t*\tMD:Z:10^TT123^TT10"); Support.createBam(data,normalBAM); @@ -128,9 +127,9 @@ public void germlineTest1() throws IOException{ assertFalse(re.getInfo().contains(VcfHeaderUtils.INFO_SOMATIC)); assertTrue(re.getFilter().contains(IndelUtils.FILTER_COVN8)); assertTrue(re.getFilter().contains(IndelUtils.FILTER_NBIAS)); //germline, strong support 7>=3 and all in one strand - assertTrue(re.getSampleFormatRecord(1).getField("ACINDEL").equals("1,7,7,7[7,0],7[1],0,0,7")); - assertTrue(re.getInfoRecord().getField(IndelUtils.INFO_NIOC).equals("0")); // 0/7 == 0 - assertTrue(re.getInfoRecord().getField(IndelUtils.INFO_SSOI).equals("1.000")); // 7/7 == 0 + assertEquals("1,7,7,7[7,0],7[1],0,0,7", re.getSampleFormatRecord(1).getField("ACINDEL")); + assertEquals("0", re.getInfoRecord().getField(IndelUtils.INFO_NIOC)); // 0/7 == 0 + assertEquals("1.000", re.getInfoRecord().getField(IndelUtils.INFO_SSOI)); // 7/7 == 0 } } @@ -144,9 +143,9 @@ public void germlineTest1() throws IOException{ if(re.getChromosome().equals("chrY")){ //System.out.println(re.toString()); assertTrue(re.getFilter().contains(IndelUtils.FILTER_COVT )); //germline, tumour with coverge 7 - assertTrue(re.getSampleFormatRecord(1).getField("ACINDEL").equals("2,12,11,3[1,2],4[3],2,4,4")); - assertTrue(re.getInfoRecord().getField(IndelUtils.INFO_NIOC).equals("0.333")); // 4/12 == 0.333 - assertTrue(re.getInfoRecord().getField(IndelUtils.INFO_SSOI).equals("0.273")); // 3/11 == 0.273 why not 0.272 + assertEquals("2,12,11,3[1,2],4[3],2,4,4", re.getSampleFormatRecord(1).getField("ACINDEL")); + assertEquals("0.333", re.getInfoRecord().getField(IndelUtils.INFO_NIOC)); // 4/12 == 0.333 + assertEquals("0.273", re.getInfoRecord().getField(IndelUtils.INFO_SSOI)); // 3/11 == 0.273 why not 0.272 } } //don't need delete output in tmp folder @@ -156,7 +155,7 @@ public void germlineTest1() throws IOException{ //tumour("ACINDEL").equals("1,8,8,8[8,0],0,0,8") ; germline indel but passed all filter public void germlineTest2() throws IOException{ //normal BAM with one novel start - List data = new ArrayList(); + List data = new ArrayList<>(); for(int i = 1; i <= 8; i ++) data.add("ST-" + i + ":a:102\t99\tchrY\t2672601\t60\t10M2D123M2D10M8S\t=\t2673085\t631\tGTAGTTTATATTTCTGTGGGGTCAGTGGTGATATCCCTTTTATTATTTTTTATTGTGTCTTTTTGATTCTTCTCTCTTTTCTTTTTTATTAATCTACCTAGCAGTCTATCTTATTGGGTGTG\t*\tMD:Z:10^TT123^TT10"); Support.createBam(data,tumourBAM); @@ -167,10 +166,10 @@ public void germlineTest2() throws IOException{ try (VcfFileReader reader = new VcfFileReader(output)) { for (VcfRecord re : reader) { if(re.getChromosome().equals("chrY")){ - assertFalse( re.getInfo().contains(VcfHeaderUtils.INFO_SOMATIC)); - assertTrue(re.getFilter().equals(IndelUtils.FILTER_NNS)); - assertTrue(re.getSampleFormatRecord(2).getField("ACINDEL").equals("1,8,8,8[8,0],8[1],0,0,8")); - assertTrue(re.getSampleFormatRecord(1).getField("ACINDEL").equals("2,12,11,3[1,2],4[3],2,4,4")); + assertFalse( re.getInfo().contains(VcfHeaderUtils.INFO_SOMATIC)); + assertEquals(IndelUtils.FILTER_NNS, re.getFilter()); + assertEquals("1,8,8,8[8,0],8[1],0,0,8", re.getSampleFormatRecord(2).getField("ACINDEL")); + assertEquals("2,12,11,3[1,2],4[3],2,4,4", re.getSampleFormatRecord(1).getField("ACINDEL")); } } } @@ -183,7 +182,7 @@ public void partialTest() throws IOException{ // somatic: normal BAM with zero novel start three partial reads //normal BAM don't have indel evident - List data = new ArrayList(); + List data = new ArrayList<>(); for(int i = 1; i <= 3; i ++) data.add("ST-" + i + ":c:104\t99\tchrY\t2672696\t60\t40M3D111M\t=\t2672957\t412\tATCTACCTAGCAGTCTATCTTATTGGGTGTGTGTGTGTGATTTTTTTTTTTTCCAAAAAACCAGTTCCTGAATTCATTGATTTTTTGAAGGGTTTTTTGTGTCACTGTCCCCTT\t*"); Support.createBam(data,normalBAM); @@ -213,13 +212,13 @@ public void partialTest() throws IOException{ Support.runQ3IndelNoHom(ini_noquery.getAbsolutePath()); try (VcfFileReader reader = new VcfFileReader(output)) { for (VcfRecord re : reader) { - if(re.getChromosome().equals("chrY")){ - assertTrue(!re.getInfo().contains(VcfHeaderUtils.INFO_SOMATIC)); //NOT somatic: support 46 reads of 50 informative reads + if(re.getChromosome().equals("chrY")){ + assertFalse(re.getInfo().contains(VcfHeaderUtils.INFO_SOMATIC)); //NOT somatic: support 46 reads of 50 informative reads assertTrue(re.getFilter().contains(VcfHeaderUtils.FILTER_NOVEL_STARTS)); //Not Somatic, so don't care nns - assertTrue(!re.getFilter().contains(VcfHeaderUtils.FILTER_COVERAGE_NORMAL_12)); //total coverage 50 - assertTrue(!re.getFilter().contains(IndelUtils.FILTER_TPART)); //partial reads 4>=3 but partial/total=8% < 10% on tumour - assertTrue(!re.getFilter().contains(IndelUtils.FILTER_TBIAS)); //not somtic, don't care TBIAS - assertTrue(re.getFilter().contains(IndelUtils.FILTER_NBIAS)); //not somtic, support read 46>3 and all in one strand + assertFalse(re.getFilter().contains(VcfHeaderUtils.FILTER_COVERAGE_NORMAL_12)); //total coverage 50 + assertFalse(re.getFilter().contains(IndelUtils.FILTER_TPART)); //partial reads 4>=3 but partial/total=8% < 10% on tumour + assertFalse(re.getFilter().contains(IndelUtils.FILTER_TBIAS)); //not somatic, don't care TBIAS + assertTrue(re.getFilter().contains(IndelUtils.FILTER_NBIAS)); //not somatic, support read 46>3 and all in one strand assertTrue(re.getFilter().contains(IndelUtils.FILTER_NPART)); //partial reads 4>= and partial/total=8% >5% on normal } } @@ -231,7 +230,7 @@ public void partialTest() throws IOException{ @Test //SOMTIC, COVN12, MIN, NNS public void somaticTest() throws IOException{ //normal BAM with one novel start, gematic.soi = 3% < 0.05 - List data = new ArrayList(); + List data = new ArrayList<>(); data.add("ST-E00139:1112:a:102\t99\tchrY\t2672601\t60\t10M2D123M2D10M8S\t=\t2673085\t631\tGTAGTTTATATTTCTGTGGGGTCAGTGGTGATATCCCTTTTATTATTTTTTATTGTGTCTTTTTGATTCTTCTCTCTTTTCTTTTTTATTAATCTACCTAGCAGTCTATCTTATTGGGTGTG\t*\tMD:Z:10^TT12^TT10M"); for(int i = 1; i <= 10; i ++) @@ -242,7 +241,7 @@ public void somaticTest() throws IOException{ IndelMTTest.createDelBam(tumourBAM); File controlVcf = testFolder.newFile("control.vcf"); - data.clear();; + data.clear(); data.add(VcfHeaderUtils.STANDARD_FINAL_HEADER_LINE_INCLUDING_FORMAT+"s1"); data.add("chr11 2672739 . ATT A 123.86 . . GT 0/1"); //Support.createVcf(data, data, "control.vcf"); @@ -260,11 +259,11 @@ public void somaticTest() throws IOException{ assertTrue(re.getInfo().contains("GATKINFO")); //make sure GATK INFO column still exists assertTrue(re.getFilter().contains(IndelUtils.FILTER_COVN12)); assertTrue(re.getFilter().contains(IndelUtils.FILTER_MIN)); - assertTrue(re.getFilter().contains(IndelUtils.FILTER_NNS)); - assertTrue(re.getSampleFormatRecord(1).getField("ACINDEL").equals("1,11,11,1[1,0],1[1],0,10,1")); - assertTrue(re.getSampleFormatRecord(2).getField("ACINDEL").equals("2,12,11,3[1,2],4[3],2,4,4")); - assertTrue(re.getInfoRecord().getField(IndelUtils.INFO_NIOC).equals("0.333")); // 4/12 == 0.333 - assertTrue(re.getInfoRecord().getField(IndelUtils.INFO_SSOI).equals("0.273")); // 3/11 == 0.273 why not 0.272 + assertTrue(re.getFilter().contains(IndelUtils.FILTER_NNS)); + assertEquals("1,11,11,1[1,0],1[1],0,10,1", re.getSampleFormatRecord(1).getField("ACINDEL")); + assertEquals("2,12,11,3[1,2],4[3],2,4,4", re.getSampleFormatRecord(2).getField("ACINDEL")); + assertEquals("0.333", re.getInfoRecord().getField(IndelUtils.INFO_NIOC)); // 4/12 == 0.333 + assertEquals("0.273", re.getInfoRecord().getField(IndelUtils.INFO_SSOI)); // 3/11 == 0.273 why not 0.272 } } diff --git a/q3indel/test/au/edu/qimr/indel/pileup/QFlagTest.java b/q3indel/test/au/edu/qimr/indel/pileup/QFlagTest.java index daa99109b..c94ee1ec2 100644 --- a/q3indel/test/au/edu/qimr/indel/pileup/QFlagTest.java +++ b/q3indel/test/au/edu/qimr/indel/pileup/QFlagTest.java @@ -1,8 +1,5 @@ package au.edu.qimr.indel.pileup; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -19,6 +16,8 @@ import au.edu.qimr.indel.IniFileTest; import au.edu.qimr.indel.Support; +import static org.junit.Assert.*; + public class QFlagTest { File test_vcf; @@ -67,14 +66,14 @@ public void gematic_soiTest() throws IOException{ //gemline since control 100% supporting even only one record try (VcfFileReader reader = new VcfFileReader(outputVcfFile)){ - for (VcfRecord re : reader) { - assertTrue(re.getSampleFormatRecord(2).getField("ACINDEL").equals("2,12,11,3[1,2],4[3],2,4,4")); - assertTrue(re.getSampleFormatRecord(1).getField("ACINDEL").equals("0,1,1,0[0,0],1[1],0,0,1")); + for (VcfRecord re : reader) { + assertEquals("2,12,11,3[1,2],4[3],2,4,4", re.getSampleFormatRecord(2).getField("ACINDEL")); + assertEquals("0,1,1,0[0,0],1[1],0,0,1", re.getSampleFormatRecord(1).getField("ACINDEL")); //germline reads - assertFalse(re.getInfo().contains("SOMATIC")); - assertTrue(re.getInfoRecord().getField(IndelUtils.INFO_NIOC).equals("0")); - assertTrue(re.getInfoRecord().getField(IndelUtils.INFO_SSOI).equals("0")); + assertFalse(re.getInfo().contains("SOMATIC")); + assertEquals("0", re.getInfoRecord().getField(IndelUtils.INFO_NIOC)); + assertEquals("0", re.getInfoRecord().getField(IndelUtils.INFO_SSOI)); assertTrue(re.getFilter().contains("COVN8")); assertFalse(re.getFilter().contains("MIN")); @@ -98,13 +97,13 @@ public void gematic_soiTest() throws IOException{ Support.createBam(data, control_bam); Support.runQ3IndelNoHom( ini.getAbsolutePath()); try (VcfFileReader reader = new VcfFileReader(outputVcfFile)){ - for (VcfRecord re : reader) { - assertTrue(re.getSampleFormatRecord(2).getField("ACINDEL").equals("2,12,11,3[1,2],4[3],2,4,4")); - assertTrue(re.getSampleFormatRecord(1).getField("ACINDEL").equals("0,7,7,0[0,0],1[1],6,0,4")); + for (VcfRecord re : reader) { + assertEquals("2,12,11,3[1,2],4[3],2,4,4", re.getSampleFormatRecord(2).getField("ACINDEL")); + assertEquals("0,7,7,0[0,0],1[1],6,0,4", re.getSampleFormatRecord(1).getField("ACINDEL")); //somatic reads - assertTrue(re.getInfo().contains("SOMATIC")); - assertTrue(re.getInfoRecord().getField(IndelUtils.INFO_NIOC).equals("0.333")); - assertTrue(re.getInfoRecord().getField(IndelUtils.INFO_SSOI).equals("0.273")); + assertTrue(re.getInfo().contains("SOMATIC")); + assertEquals("0.333", re.getInfoRecord().getField(IndelUtils.INFO_NIOC)); + assertEquals("0.273", re.getInfoRecord().getField(IndelUtils.INFO_SSOI)); assertFalse(re.getFilter().contains("COVN8")); assertTrue(re.getFilter().contains("MIN")); diff --git a/q3indel/test/au/edu/qimr/indel/pileup/ReadIndelsTest.java b/q3indel/test/au/edu/qimr/indel/pileup/ReadIndelsTest.java index fbed0abef..a56bbf2c4 100644 --- a/q3indel/test/au/edu/qimr/indel/pileup/ReadIndelsTest.java +++ b/q3indel/test/au/edu/qimr/indel/pileup/ReadIndelsTest.java @@ -51,24 +51,24 @@ public void multiAltTest(){ ReadIndels indelload = new ReadIndels(QLoggerFactory.getLogger(Main.class, null, null)); indelload.loadIndels(input3); Map positionRecordMap = indelload.getIndelMap(); - assertTrue(positionRecordMap.size() == 1); + assertEquals(1, positionRecordMap.size()); for( ChrPosition key : positionRecordMap.keySet()){ IndelPosition indel = positionRecordMap.get(key); - assertTrue(indel.getIndelVcfs().size() == 1); + assertEquals(1, indel.getIndelVcfs().size()); assertEquals("C", indel.getIndelVcf(0).getAlt()); //check format GT field - List format = indel.getIndelVcfs().get(0).getFormatFields(); + List format = indel.getIndelVcfs().getFirst().getFormatFields(); VcfFormatFieldRecord record = new VcfFormatFieldRecord(format.get(0), format.get(1)); - assertTrue(record.getField("GT").equals(".")); + assertEquals(".", record.getField("GT")); record = new VcfFormatFieldRecord(format.get(0), format.get(2)); - assertTrue(record.getField("GT").equals(".")); + assertEquals(".", record.getField("GT")); } }catch(Exception e){ - assertFalse(true); + fail(); } } @@ -78,14 +78,14 @@ public void appendIndelsTest(){ try{ ReadIndels indelload = new ReadIndels(QLoggerFactory.getLogger(Main.class, null, null)); - indelload.loadIndels(input1); - assertTrue(getHeaderLineCounts(indelload.getVcfHeader()) == 7); + indelload.loadIndels(input1); + assertEquals(7, getHeaderLineCounts(indelload.getVcfHeader())); //in case of GATK, take the second sample column indelload.appendTestIndels(input2); - assertTrue(getHeaderLineCounts(indelload.getVcfHeader()) == 8); + assertEquals(8, getHeaderLineCounts(indelload.getVcfHeader())); Map positionRecordMap = indelload.getIndelMap(); - assertTrue(positionRecordMap.size() == 3); + assertEquals(3, positionRecordMap.size()); for( ChrPosition key : positionRecordMap.keySet()){ IndelPosition indel = positionRecordMap.get(key); if(indel.getStart() == 59033287){ @@ -94,32 +94,32 @@ public void appendIndelsTest(){ assertEquals("GT:AD:DP:GD:GQ:PL", indel.getIndelVcf(0).getFormatFields().get(0)); assertEquals("0/0:0:0:GT/GT:0:0,0,0", indel.getIndelVcf(0).getFormatFields().get(1)); assertEquals("0/1:131,31:162:GT/G:99:762,0,4864", indel.getIndelVcf(0).getFormatFields().get(2)); - assertTrue(indel.getIndelVcf(0).getInfo().equals("SOMATIC1")); //info column from first file + assertEquals("SOMATIC1", indel.getIndelVcf(0).getInfo()); //info column from first file }else if(indel.getStart() == 59033423){ //merge indels but split alleles assertEquals("0/1:7,4:11:T/TC:99:257,0,348", indel.getIndelVcf(0).getFormatFields().get(1)); assertEquals(".:7,5:.:T/A:.:.", indel.getIndelVcf(0).getFormatFields().get(2)); assertEquals("./.:.:.", indel.getIndelVcf(1).getFormatFields().get(1)); assertEquals(".:T/A:7,5", indel.getIndelVcf(1).getFormatFields().get(2)); - assertTrue(indel.getIndelVcf(0).getInfo().equals("SOMATIC1" )); //info column from first file - assertTrue(indel.getIndelVcf(1).getInfo().equals("SOMATIC" )); //info column from second file + assertEquals("SOMATIC1", indel.getIndelVcf(0).getInfo()); //info column from first file + assertEquals("SOMATIC", indel.getIndelVcf(1).getInfo()); //info column from second file }else if(indel.getStart() == 59033286){ //indels only appear on second file, assertEquals("0/1:GGT/G:131,31:162:99:762,0,4864", indel.getIndelVcf(0).getFormatFields().get(2)); - assertEquals("./.:.:.:.:.:.", indel.getIndelVcf(0).getFormatFields().get(1)); - assertTrue(indel.getIndelVcf(0).getInfo().equals("SOMATIC" )); //info column from second file + assertEquals("./.:.:.:.:.:.", indel.getIndelVcf(0).getFormatFields().get(1)); + assertEquals("SOMATIC", indel.getIndelVcf(0).getInfo()); //info column from second file } } }catch(Exception e){ System.err.println(Q3IndelException.getStrackTrace(e)); - assertFalse(true); + fail(); } } @Test - //test different records with same hascode, but hashCode() can change from Java versions - public void LoadIndelsTest2() { - List data = new ArrayList(); + //test different records with same hashcode, but hashCode() can change from Java versions + public void loadIndelsTest2() { + List data = new ArrayList<>(); data.add("chr2\t71697867\t.\tTTTCC\tT\t115.73\t.\tAC=1;AF=0.500;AN=2;BaseQRankSum=0.361;ClippingRankSum=-0.361;DP=11;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=60.00;MQ0=0;MQRankSum=1.881;QD=10.52;ReadPosRankSum=-0.922;SOR=1.609\tGT:AD:DP:GQ:PL\t0/1:5,4:9:99:153,0,145"); data.add("chr2\t241133989\t.\tGAGGTGGAGCGTAGTGTTGAAATTGCATCCATTGTGGGGCAGTGTTGGA\tG\t457.73\t.\t AC=1;AF=0.500;AN=2;BaseQRankSum=2.462;ClippingRankSum=-0.359;DP=26;FS=3.628;MLEAC=1;MLEAF=0.500;MQ=59.33;MQ0=0;MQRankSum=-2.103;QD=17.61;ReadPosRankSum=-0.449;SOR=0.991\tGT:AD:DP:GQ:PL\t0/1:13,13:26:99:495,0,2645"); @@ -127,77 +127,74 @@ public void LoadIndelsTest2() { ReadIndels indelload = new ReadIndels(QLoggerFactory.getLogger(Main.class, null, null)); try{ - //load single file + //load a single file indelload.loadIndels(input1); Map positionRecordMap = indelload.getIndelMap(); - assertTrue(positionRecordMap.size() == 2); + assertEquals(2, positionRecordMap.size()); - int code1 = 0, code2 = 0; for( ChrPosition key : positionRecordMap.keySet()){ IndelPosition indel = positionRecordMap.get(key); - if(indel.getStart() == 71697868 && indel.getFullChromosome().equals("chr2")){ - indel.getMotif(0).equals("TTCC"); - code1 = indel.getIndelVcf(0).hashCode(); - }else if(indel.getStart() == 241133990 && indel.getFullChromosome().equals("chr2")){ - indel.getMotif(0).equals("AGGTGGAGCGTAGTGTTGAAATTGCATCCATTGTGGGGCAGTGTTGGA"); - code2 = indel.getIndelVcf(0).hashCode(); - }else - assertFalse(true); + if (indel.getStart() == 71697868 && indel.getFullChromosome().equals("chr2")){ + assertEquals("TTCC", indel.getMotif(0)); + } else if (indel.getStart() == 241133990 && indel.getFullChromosome().equals("chr2")){ + assertEquals("AGGTGGAGCGTAGTGTTGAAATTGCATCCATTGTGGGGCAGTGTTGGA", indel.getMotif(0)); + } else + fail(); //can't run it for all environment } }catch(Exception e){ System.out.println(Q3IndelException.getStrackTrace(e)); - assertFalse(true); + fail(); } } @Test //load inputs only in case of pindel - public void LoadIndelsTest() { + public void loadIndelsTest() { // createVcf(); ReadIndels indelload = new ReadIndels(QLoggerFactory.getLogger(Main.class, null, null)); try{ //load single file - indelload.loadIndels(input1); - assertTrue(getHeaderLineCounts(indelload.getVcfHeader()) == 7); + indelload.loadIndels(input1); + assertEquals(7, getHeaderLineCounts(indelload.getVcfHeader())); //load second file, in case of pindel - indelload.loadIndels(input2); - assertTrue(getHeaderLineCounts(indelload.getVcfHeader()) == 8); + indelload.loadIndels(input2); + assertEquals(8, getHeaderLineCounts(indelload.getVcfHeader())); Map positionRecordMap = indelload.getIndelMap(); - assertTrue(positionRecordMap.size() == 3); + assertEquals(3, positionRecordMap.size()); for( ChrPosition key : positionRecordMap.keySet()){ IndelPosition indel = positionRecordMap.get(key); - assertFalse(indel.getIndelVcf(0).getFormatFields().get(1).equals(indel.getIndelVcf(0).getFormatFields().get(2))); - if(indel.getStart() == 59033423){ - assertTrue( indel.getMotif(0).equals("C")); - assertTrue( indel.getMotif(1).equals("CG")); + assertNotEquals(indel.getIndelVcf(0).getFormatFields().get(1), indel.getIndelVcf(0).getFormatFields().get(2)); + if(indel.getStart() == 59033423){ + assertEquals("C", indel.getMotif(0)); + assertEquals("CG", indel.getMotif(1)); //check GT:GD from existing one, no long overwrite existing one - assertTrue(indel.getIndelVcf(0).getFormatFields().get(0).equals("GT:GD:AD:DP:GQ:PL")); - assertTrue(indel.getIndelVcf(0).getFormatFields().get(1).equals("0/1:T/TC:7,4:11:99:257,0,348")); - assertTrue(indel.getIndelVcf(0).getFormatFields().get(2).equals("0/1:T/TC:17,2:19:72:72,0,702")); - assertTrue(indel.getIndelVcf(1).getFormatFields().get(1).equals(".:T/A:7,5")); - assertTrue(indel.getIndelVcf(1).getFormatFields().get(2).equals(".:A/TC:9,9")); + assertEquals("GT:GD:AD:DP:GQ:PL", indel.getIndelVcf(0).getFormatFields().get(0)); + assertEquals("0/1:T/TC:7,4:11:99:257,0,348", indel.getIndelVcf(0).getFormatFields().get(1)); + assertEquals("0/1:T/TC:17,2:19:72:72,0,702", indel.getIndelVcf(0).getFormatFields().get(2)); + assertEquals(".:T/A:7,5", indel.getIndelVcf(1).getFormatFields().get(1)); + assertEquals(".:A/TC:9,9", indel.getIndelVcf(1).getFormatFields().get(2)); } } //change inputs order indelload = new ReadIndels(QLoggerFactory.getLogger(Main.class, null, null)); - indelload.loadIndels(input2); - - assertTrue(getHeaderLineCounts(indelload.getVcfHeader()) == 7); + indelload.loadIndels(input2); + + assertEquals(7, getHeaderLineCounts(indelload.getVcfHeader())); //load second file, in case of pindel indelload.loadIndels(input1); - assertTrue(getHeaderLineCounts(indelload.getVcfHeader()) == 8); + assertEquals(8, getHeaderLineCounts(indelload.getVcfHeader())); }catch(Exception e){ System.out.println(Q3IndelException.getStrackTrace(e)); - assertFalse(true); + fail(); } } @@ -211,22 +208,22 @@ private int getHeaderLineCounts(VcfHeader header){ public void createVcf(){ - List head = new ArrayList(); + List head = new ArrayList<>(); head.add("##fileformat=VCFv4.1"); head.add("##FILTER="); head.add("##INFO="); head.add("##contig="); head.add("##contig="); - List head1 = new ArrayList(head); + List head1 = new ArrayList<>(head); head1.add("##INFO="); head1.add(VcfHeaderUtils.STANDARD_FINAL_HEADER_LINE + "\tFORMAT\tS1\tS2"); - List data1 = new ArrayList(); + List data1 = new ArrayList<>(); data1.add("chrY 59033286 . GT G 724.73 PASS SOMATIC1 GT:AD:DP:GQ:PL 0/0:0:0:0:0,0,0 0/1:80,17:97:99:368,0,3028"); data1.add("chrY 59033423 . T TC 219.73 PASS SOMATIC1 GT:AD:DP:GQ:PL 0/1:7,4:11:99:257,0,348 0/1:17,2:19:72:72,0,702"); Support.createVcf(head1, data1, input1); - head1 = new ArrayList(head); + head1 = new ArrayList<>(head); head1.add("##PG=\"creating second file\""); head1.add(VcfHeaderUtils.STANDARD_FINAL_HEADER_LINE + "\tFORMAT\tS1\tS2"); data1.clear(); diff --git a/q3indel/test/au/edu/qimr/indel/pileup/SingleModeTest.java b/q3indel/test/au/edu/qimr/indel/pileup/SingleModeTest.java index f50cabd1f..b25ccb5db 100644 --- a/q3indel/test/au/edu/qimr/indel/pileup/SingleModeTest.java +++ b/q3indel/test/au/edu/qimr/indel/pileup/SingleModeTest.java @@ -1,7 +1,6 @@ package au.edu.qimr.indel.pileup; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; @@ -52,7 +51,7 @@ public void GATKNormalTest() throws Exception { for (VcfRecord re : reader) { if(re.getChromosome().equals("chrY")){ assertEquals(".", re.getSampleFormatRecord(2).getField("ACINDEL")); - assertTrue(re.getSampleFormatRecord(1).getField("ACINDEL").equals("1,1,1,1[1,0],1[1],0,0,1") ); + assertEquals("1,1,1,1[1,0],1[1],0,0,1", re.getSampleFormatRecord(1).getField("ACINDEL")); } } } @@ -70,8 +69,8 @@ public void GATKTestTest() throws Exception{ try (VcfFileReader reader = new VcfFileReader(outputVcfFile)) { for (VcfRecord re : reader) if(re.getChromosome().equals("chrY")){ - assertTrue(re.getSampleFormatRecord(1).getField("ACINDEL").equals(".") ); - assertTrue(re.getSampleFormatRecord(2).getField("ACINDEL").equals("1,1,1,1[1,0],1[1],0,0,1") ); + assertEquals(".", re.getSampleFormatRecord(1).getField("ACINDEL")); + assertEquals("1,1,1,1[1,0],1[1],0,0,1", re.getSampleFormatRecord(2).getField("ACINDEL")); } } }