public Pair<Long, Long> reduceInit() { return new Pair<Long, Long>(0L, 0L); }
public Pair<ExpandingArrayList<Long>, Long> reduce(Datum point, Pair<ExpandingArrayList<Long>, Long> sum) { ExpandingArrayList<Long> counts = sum.getFirst(); updateCounts(counts, point.nRodsAtThisLocation, 1); updateCounts(counts, 0, point.nSkippedBases); Pair<ExpandingArrayList<Long>, Long> r = new Pair<ExpandingArrayList<Long>, Long>(counts, point.nTotalBases + sum.getSecond()); //System.out.printf("Reduce: %s %s => %s%n", point, sum, r); return r; } }
/** * Finds in the tree the node with the lowest penalty whose subnodes are all leaves * * @return the node and its penalty, or null if no such node exists */ private Pair<RecalDatumNode<T>, Double> getMinPenaltyAboveLeafNode() { if ( isLeaf() ) // not allowed to remove leafs directly return null; if ( isAboveOnlyLeaves() ) // we only consider removing nodes above all leaves return new Pair<RecalDatumNode<T>, Double>(this, getPenalty()); else { // just recurse, taking the result with the min penalty of all subnodes Pair<RecalDatumNode<T>, Double> minNode = null; for ( final RecalDatumNode<T> sub : subnodes ) { final Pair<RecalDatumNode<T>, Double> subFind = sub.getMinPenaltyAboveLeafNode(); if ( subFind != null && (minNode == null || subFind.getSecond() < minNode.getSecond()) ) { minNode = subFind; } } return minNode; } }
/** * The function assumes that read contains the variant allele. * * @param read * @param variantStartPosition the location of the variant in the reference * @return */ protected Pair<OptionalInt, OptionalInt> getVariantPositionInRead(final GATKSAMRecord read, final int variantStartPosition) { final Pair<Integer, Boolean> refPositionAndDeletionFlag = ReadUtils.getReadCoordinateForReferenceCoordinate(read.getSoftStart(), read.getCigar(), variantStartPosition, true); // the +1 is needed there because getReadCoordinateForReferenceCoordinate() returns the number of read bases from the left end to the variant - 1 int numReadBasesFromLeftEndToVariant = refPositionAndDeletionFlag.getFirst() + 1; // we don't take advantage of fallsInsideOrJustBeforeDeletionOrSkippedRegion flag now, but we might want to, so I will leave it here in comments. // boolean fallsInsideOrJustBeforeDeletionOrSkippedRegion = refPositionAndDeletionFlag.getSecond(); if ( numReadBasesFromLeftEndToVariant == ReadUtils.CLIPPING_GOAL_NOT_REACHED ) { return new Pair(OptionalInt.empty(), OptionalInt.empty()); } else { int leftOffset = numReadBasesFromLeftEndToVariant - 1; int rightOffset = read.getReadLength() - numReadBasesFromLeftEndToVariant; return new Pair(OptionalInt.of(leftOffset), OptionalInt.of(rightOffset)); } }
/** * Checks whether there is a non-empty left flanking non-variant trimmed out region. * @return {@code true} if there is a non-trivial left flank region, {@code false} otherwise. */ public boolean hasLeftFlankingRegion() { return ! nonVariantFlanks.getFirst().isUnmapped(); }
private static String formatArguments( Collection<Pair<ArgumentDefinition,String>> invalidArgumentValues ) { StringBuilder sb = new StringBuilder(); for( Pair<ArgumentDefinition,String> invalidValue: invalidArgumentValues ) { if(invalidValue.getSecond() == null) sb.append( String.format("%nArgument '--%s' requires a value but none was provided", invalidValue.first.fullName) ); else sb.append( String.format("%nArgument '--%s' has value of incorrect format: %s (should match %s)", invalidValue.first.fullName, invalidValue.second, invalidValue.first.validation) ); } return sb.toString(); } }
private boolean containsDuplicateRecord( final File vcf, final GenomeLocParser parser ) { final List<Pair<GenomeLoc, HaplotypeCallerGenotypingEngine.Event>> VCs = new ArrayList<>(); try { for( final VariantContext vc : GATKVCFUtils.readVCF(vcf).getSecond() ) { VCs.add(new Pair<>(parser.createGenomeLoc(vc), new HaplotypeCallerGenotypingEngine.Event(vc))); } } catch( IOException e ) { throw new IllegalStateException("Somehow the temporary VCF from the integration test could not be read."); } final Set<Pair<GenomeLoc, HaplotypeCallerGenotypingEngine.Event>> VCsAsSet = new HashSet<>(VCs); return VCsAsSet.size() != VCs.size(); // The se will remove duplicate Events. }
/** * Returns the trimmed out left non-variant region. * <p/> * Notice that in case of no variation, the whole original region is considered the left flanking region. * * @throws IllegalStateException if there is not such as left flanking region. */ public ActiveRegion nonVariantLeftFlankRegion() { if (leftFlankRegion == null && ! nonVariantFlanks.getFirst().isUnmapped()) leftFlankRegion = originalRegion.trim(nonVariantFlanks.getFirst(),originalRegion.getExtension()); else if (nonVariantFlanks.getFirst().isUnmapped()) throw new IllegalStateException("there is no left flank non-variant trimmed out region"); return leftFlankRegion; }
/** * Returns a Pair of (main, synonym) names for argument with fullName s1 and * shortName s2. * * Previously we had it so the main name was selected to be the longest of the two, provided * it didn't exceed MAX_DISPLAY_NAME, in which case the shorter was taken. But we now disable * the length-based name rearrangement in order to maintain consistency in the GATKDocs table. * * This may cause messed up spacing in the CLI-help display but we don't care as much about that * since more users use the online GATKDocs for looking up arguments. * * @param s1 the short argument name without -, or null if not provided * @param s2 the long argument name without --, or null if not provided * @return A pair of fully qualified names (with - or --) for the argument. The first * element is the primary display name while the second (potentially null) is a * synonymous name. */ Pair<String, String> displayNames(String s1, String s2) { s1 = s1 == null ? null : "-" + s1; s2 = s2 == null ? null : "--" + s2; if (s1 == null) return new Pair<String, String>(s2, null); if (s2 == null) return new Pair<String, String>(s1, null); return new Pair<String, String>(s2, s1); }
/** * Checks whether there is a non-empty right flanking non-variant trimmed out region. * @return {@code true} if there is a non-trivial right flank region, {@code false} otherwise. */ public boolean hasRightFlankingRegion() { return ! nonVariantFlanks.getSecond().isUnmapped(); }
@Test(dataProvider = "PRTest") public void testPR(final int nct, PRTest params) { WalkerTestSpec spec = new WalkerTestSpec( "-T PrintReads" + " -R " + hg18Reference + " -I " + privateTestDir + "HiSeq.1mb.1RG.bam" + " -nct " + nct + " --no_pg_tag" + " -BQSR " + privateTestDir + "HiSeq.20mb.1RG.table" + params.args + " -o %s", Arrays.asList(params.md5)); executeTest("testPrintReads-"+params.args, spec).getFirst(); }
@Override public Set<Pair<? extends KBestSubHaplotypeFinder, String>> subFinderLabels() { final int subFinderCount = subFinders.size(); final String edgeCost = String.format("%.2f",-Math.log10((double) subFinderCount)); final Set<Pair<? extends KBestSubHaplotypeFinder,String>> result = new LinkedHashSet<>(subFinderCount); for (final KBestSubHaplotypeFinder subFinder : subFinders) result.add(new Pair<>(subFinder,edgeCost)); return result; }
/** * Returns the trimmed out right non-variant region. */ public ActiveRegion nonVariantRightFlankRegion() { if (rightFlankRegion == null && ! nonVariantFlanks.getSecond().isUnmapped()) rightFlankRegion = originalRegion.trim(nonVariantFlanks.getSecond(),originalRegion.getExtension()); else if (nonVariantFlanks.getSecond().isUnmapped()) throw new IllegalStateException("there is no right flank non-variant trimmed out region"); return rightFlankRegion; }
/** * General interval reduce routine called after all of the traversals are done * @param results interval reduce results */ public void onTraversalDone(List<Pair<GenomeLoc, ReduceType>> results) { for ( Pair<GenomeLoc, ReduceType> result : results ) { logger.info(String.format("[INTERVAL REDUCE RESULT] at %s ", result.getFirst())); this.onTraversalDone(result.getSecond()); } }