@Override public List<Interval> takeSome(final Interval interval, final long idealSplitWeight, final long currentSize, final double projectedSizeOfRemaining) { final long projectedSize = currentSize + intervalWeight(interval); if (shouldIncludeInterval(idealSplitWeight, projectedSizeOfRemaining, projectedSize)) { return CollectionUtil.makeList(interval, null); } else { return CollectionUtil.makeList(null, interval); } }
IntervalListInputType(final String... s) { applicableExtensions = CollectionUtil.makeSet(s); }
/** For any given TileTemplateRead, we want to make sure that there is only a single TilePhasingValue */ private static Collection<TilePhasingValue> ensureSoleTilePhasingValuesPerRead(final Collection<TilePhasingValue> tilePhasingValues) { final Map<TileTemplateRead, List<TilePhasingValue>> partitionedMap = tilePhasingValues.stream().collect(Collectors.groupingBy(TilePhasingValue::getTileTemplateRead)); final Collection<TilePhasingValue> newTilePhasingValues = new LinkedList<>(); for (final TileTemplateRead read : partitionedMap.keySet()) { newTilePhasingValues.add(CollectionUtil.getSoleElement(partitionedMap.get(read))); } return newTilePhasingValues; } }
if (CollectionUtil.makeList(momGt, dadGt, kidGt).stream().anyMatch(gt -> gt.isHetNonRef() || Stream.concat(Stream.of(ctx.getReference()), gt.getAlleles().stream()).anyMatch(a -> a.length() != 1 || a.isSymbolic()))) { CollectionUtil.makeList(momGt, dadGt, kidGt) .stream() .flatMap(gt -> gt.getAlleles().stream())) builder.genotypes(ctx.getGenotypes().subsetToSamples(CollectionUtil.makeSet(trio.MOTHER, trio.FATHER, trio.OFFSPRING))); builder.attribute(MENDELIAN_VIOLATION_KEY, type.name());
/** * Executes the given R script that is stored in a file by a call to Rscript. * Blocks until the R script is complete. * * @param scriptFile the file object for the script * @param arguments any arguments required by the script * @return the return code of the R process */ public static int executeFromFile(final File scriptFile, final String... arguments) { final String[] command = new String[arguments.length + 2]; command[0] = R_EXE; command[1] = scriptFile.getAbsolutePath(); System.arraycopy(arguments, 0, command, 2, arguments.length); LOG.info(String.format("Executing R script via command: %s", CollectionUtil.join(Arrays.asList(command), " "))); return ProcessExecutor.execute(command); }
@Test(dataProvider = "overlapsSingletonData") public void testOverlapsSingletonAsListIntervalList(final IntervalList fromLists, final IntervalList whatLists, final IntervalList list) { Assert.assertEquals( CollectionUtil.makeCollection(IntervalList.overlaps(Collections.singletonList(fromLists), Collections.singletonList(whatLists)).iterator()), CollectionUtil.makeCollection(list.iterator())); }
if (CollectionUtil.makeList(momGt, dadGt, kidGt).stream().anyMatch(gt -> gt.isHetNonRef() || Stream.concat(Stream.of(ctx.getReference()), gt.getAlleles().stream()).anyMatch(a -> a.length() != 1 || a.isSymbolic()))) { CollectionUtil.makeList(momGt, dadGt, kidGt) .stream() .flatMap(gt -> gt.getAlleles().stream())) builder.genotypes(ctx.getGenotypes().subsetToSamples(CollectionUtil.makeSet(trio.MOTHER, trio.FATHER, trio.OFFSPRING))); builder.attribute(MENDELIAN_VIOLATION_KEY, type.name());
/** * Executes the given R script that is stored in a file by a call to Rscript. * Blocks until the R script is complete. * * @param scriptFile the file object for the script * @param arguments any arguments required by the script * @return the return code of the R process */ public static int executeFromFile(final File scriptFile, final String... arguments) { final String[] command = new String[arguments.length + 2]; command[0] = R_EXE; command[1] = scriptFile.getAbsolutePath(); System.arraycopy(arguments, 0, command, 2, arguments.length); LOG.info(String.format("Executing R script via command: %s", CollectionUtil.join(Arrays.asList(command), " "))); return ProcessExecutor.execute(command); }
@Test(dataProvider = "subtractSingletonData") public void testSubtractSingletonAsListIntervalList(final IntervalList fromLists, final IntervalList whatLists, final IntervalList list) { Assert.assertEquals( CollectionUtil.makeCollection(IntervalList.subtract(Collections.singletonList(fromLists), Collections.singletonList(whatLists)).iterator()), CollectionUtil.makeCollection(list.iterator())); }
@Override public List<VCFFilterHeaderLine> headerLines() { return CollectionUtil.makeList(new VCFFilterHeaderLine(FILTER_NAME, "Site exhibits QD value below a hard limit.")); } }
TYPE(final String... s) { applicableExtensions = CollectionUtil.makeSet(s); }
/** For any given TileTemplateRead, we want to make sure that there is only a single TilePhasingValue */ private static Collection<TilePhasingValue> ensureSoleTilePhasingValuesPerRead(final Collection<TilePhasingValue> tilePhasingValues) { final Map<TileTemplateRead, List<TilePhasingValue>> partitionedMap = tilePhasingValues.stream().collect(Collectors.groupingBy(TilePhasingValue::getTileTemplateRead)); final Collection<TilePhasingValue> newTilePhasingValues = new LinkedList<>(); for (final TileTemplateRead read : partitionedMap.keySet()) { newTilePhasingValues.add(CollectionUtil.getSoleElement(partitionedMap.get(read))); } return newTilePhasingValues; } }
/** * Reviews the qualities observed thus far and throws an exception if any are below the minimum quality threshold. */ public void assertMinimumQualities() { final Collection<String> errorTokens = new LinkedList<String>(); for (final Map.Entry<Byte, AtomicInteger> entry : this.qualityCountMap.entrySet()) { /** * We're comparing revised qualities here, not observed, but the qualities that are logged in qualityCountMap are observed * qualities. So as we iterate through it, convert observed qualities into their revised value. */ if (generateRevisedQuality(entry.getKey()) < minimumRevisedQuality) { errorTokens.add(String.format("quality %s observed %s times", entry.getKey(), entry.getValue())); } } if (!errorTokens.isEmpty()) { throw new PicardException(String.format( "Found BCL qualities that fell beneath minimum threshold of %s: %s.", minimumRevisedQuality, CollectionUtil.join(errorTokens, "; ") )); } }
@Test public void testOverlapsEmptySecondList() { Assert.assertEquals( CollectionUtil.makeCollection(IntervalList.overlaps(Collections.singletonList(list1), Collections.emptyList()).iterator()), Collections.emptyList()); }
@Override public List<VCFFilterHeaderLine> headerLines() { return CollectionUtil.makeList( new VCFFilterHeaderLine(this.filterName, "Variant Filtered by Javascript file " + this.scriptFile)); } }
IntervalListInputType(final String... s) { applicableExtensions = CollectionUtil.makeSet(s); }
/** Reads all of the stream into a String, decoding with the provided {@link java.nio.charset.Charset} then closes the stream quietly. */ public static String slurp(final InputStream is, final Charset charSet) { final List<String> tokenOrEmpty = tokenSlurp(is, charSet, "\\A"); return tokenOrEmpty.isEmpty() ? StringUtil.EMPTY_STRING : CollectionUtil.getSoleElement(tokenOrEmpty); }
/** * Reviews the qualities observed thus far and throws an exception if any are below the minimum quality threshold. */ public void assertMinimumQualities() { final Collection<String> errorTokens = new LinkedList<String>(); for (final Map.Entry<Byte, AtomicInteger> entry : this.qualityCountMap.entrySet()) { /** * We're comparing revised qualities here, not observed, but the qualities that are logged in qualityCountMap are observed * qualities. So as we iterate through it, convert observed qualities into their revised value. */ if (generateRevisedQuality(entry.getKey()) < minimumRevisedQuality) { errorTokens.add(String.format("quality %s observed %s times", entry.getKey(), entry.getValue())); } } if (!errorTokens.isEmpty()) { throw new PicardException(String.format( "Found BCL qualities that fell beneath minimum threshold of %s: %s.", minimumRevisedQuality, CollectionUtil.join(errorTokens, "; ") )); } }
@Test(dataProvider = "intersectData") public void testIntersectIntervalLists(final List<IntervalList> lists, final IntervalList list) { Assert.assertEquals( CollectionUtil.makeCollection(IntervalList.intersection(lists).iterator()), CollectionUtil.makeCollection(list.iterator())); }
@Override public List<VCFFilterHeaderLine> headerLines() { return CollectionUtil.makeList(new VCFFilterHeaderLine("StrandBias", "Site exhibits excessive allele/strand correlation.")); }