Java Code Examples for htsjdk.samtools.util.SequenceUtil#generateAllKmers()
The following examples show how to use
htsjdk.samtools.util.SequenceUtil#generateAllKmers() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CollectOxoGMetrics.java From picard with MIT License | 5 votes |
private Set<String> makeContextStrings(final int contextSize) { final Set<String> contexts = new HashSet<>(); for (final byte[] kmer : SequenceUtil.generateAllKmers(2 * contextSize + 1)) { if (kmer[contextSize] == 'C') { contexts.add(StringUtil.bytesToString(kmer)); } } log.info("Generated " + contexts.size() + " context strings."); return contexts; }
Example 2
Source File: ArtifactCounter.java From picard with MIT License | 4 votes |
public ArtifactCounter(final String sampleAlias, final String library, final int contextSize, final boolean expectedTandemReads) { this.sampleAlias = sampleAlias; this.library = library; this.contextSize = contextSize; // define the contexts final HashSet<String> fullContexts = new HashSet<>(); for (final byte[] kmer : SequenceUtil.generateAllKmers(2 * contextSize + 1)) { fullContexts.add(StringUtil.bytesToString(kmer)); } final Set<String> zeroContexts = new HashSet<>(); // the half contexts specify either leading or trailing bases. the zero context is just the center. // NB: we use N to represent a wildcard base, rather than an ambiguous base. It's assumed that all of the input // contexts are unambiguous, and that any actual N's in the data have been dealt with elsewhere. final String padding = StringUtil.repeatCharNTimes('N', contextSize); for (final String context : fullContexts) { final char centralBase = context.charAt(contextSize); final String leading = context.substring(0, contextSize) + centralBase + padding; final String trailing = padding + centralBase + context.substring(contextSize + 1, context.length()); final String zero = padding + centralBase + padding; contextMap.put(context, new RefContext(context, leading, trailing, zero)); leadingContexts.add(leading); trailingContexts.add(trailing); zeroContexts.add(zero); } final Set<String> halfContexts = new HashSet<>(leadingContexts); halfContexts.addAll(trailingContexts); this.fullContextAccumulator = new ContextAccumulator(fullContexts, expectedTandemReads); this.halfContextAccumulator = new ContextAccumulator(halfContexts, expectedTandemReads); this.zeroContextAccumulator = new ContextAccumulator(zeroContexts, expectedTandemReads); // these will get populated in the final step preAdapterSummaryMetricsList = new ArrayList<PreAdapterSummaryMetrics>(); preAdapterDetailMetricsList = new ArrayList<PreAdapterDetailMetrics>(); baitBiasSummaryMetricsList = new ArrayList<BaitBiasSummaryMetrics>(); baitBiasDetailMetricsList = new ArrayList<BaitBiasDetailMetrics>(); }