/* * Copyright (c) 2010, The Broad Institute * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ package org.broadinstitute.sting.utils.pileup; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.gatk.iterators.IterableIterator; import net.sf.samtools.SAMRecord; import java.util.List; import java.util.Collection; /** * A data retrieval interface for accessing parts of the pileup. * * @author mhanna * @version 0.1 */ public interface ReadBackedPileup extends Iterable { /** * Returns a new ReadBackedPileup that is free of deletion spanning reads in this pileup. Note that this * does not copy the data, so both ReadBackedPileups should not be changed. Doesn't make an unnecessary copy * of the pileup (just returns this) if there are no deletions in the pileup. * * @return */ public ReadBackedPileup getPileupWithoutDeletions(); /** * Returns a new ReadBackedPileup where only one read from an overlapping read * pair is retained. If the two reads in question disagree to their basecall, * neither read is retained. If they agree on the base, the read with the higher * quality observation is retained * * @return the newly filtered pileup */ public ReadBackedPileup getOverlappingFragmentFilteredPileup(); /** * Returns a new ReadBackedPileup that is free of mapping quality zero reads in this pileup. Note that this * does not copy the data, so both ReadBackedPileups should not be changed. Doesn't make an unnecessary copy * of the pileup (just returns this) if there are no MQ0 reads in the pileup. * * @return */ public ReadBackedPileup getPileupWithoutMappingQualityZeroReads(); /** Returns subset of this pileup that contains only bases with quality >= minBaseQ, coming from * reads with mapping qualities >= minMapQ. This method allocates and returns a new instance of ReadBackedPileup. * @param minBaseQ * @param minMapQ * @return */ public ReadBackedPileup getBaseAndMappingFilteredPileup( int minBaseQ, int minMapQ ); /** Returns subset of this pileup that contains only bases with quality >= minBaseQ. * This method allocates and returns a new instance of ReadBackedPileup. * @param minBaseQ * @return */ public ReadBackedPileup getBaseFilteredPileup( int minBaseQ ); /** Returns subset of this pileup that contains only bases coming from reads with mapping quality >= minMapQ. * This method allocates and returns a new instance of ReadBackedPileup. * @param minMapQ * @return */ public ReadBackedPileup getMappingFilteredPileup( int minMapQ ); /** * Returns a pileup randomly downsampled to the desiredCoverage. * * @param desiredCoverage * @return */ public ReadBackedPileup getDownsampledPileup(int desiredCoverage); /** * Returns true if any reads have been filtered out of the pileup due to excess DoC. * @return True if reads have been filtered out. False otherwise. */ public boolean hasPileupBeenDownsampled(); /** * Gets a collection of all the samples stored in this pileup. * @return Collection of samples in this pileup. */ public Collection getSamples(); /** * Gets the particular subset of this pileup with the given sample name. * @param sampleName Name of the sample to use. * @return A subset of this pileup containing only reads with the given sample. */ public ReadBackedPileup getPileupForSample(String sampleName); // todo -- delete or make private public IterableIterator extendedForeachIterator(); /** * Simple useful routine to count the number of deletion bases in this pileup * * @return */ public int getNumberOfDeletions(); public int getNumberOfMappingQualityZeroReads(); /** * @return the number of elements in this pileup */ public int size(); /** * @return the location of this pileup */ public GenomeLoc getLocation(); /** * Get counts of A, C, G, T in order, which returns a int[4] vector with counts according * to BaseUtils.simpleBaseToBaseIndex for each base. * * @return */ public int[] getBaseCounts(); /** * Somewhat expensive routine that returns true if any base in the pileup has secondary bases annotated * @return */ public boolean hasSecondaryBases(); public String getPileupString(Character ref); /** * Returns a list of the reads in this pileup. Note this call costs O(n) and allocates fresh lists each time * @return */ public List getReads(); /** * Returns a list of the offsets in this pileup. Note this call costs O(n) and allocates fresh lists each time * @return */ public List getOffsets(); /** * Returns an array of the bases in this pileup. Note this call costs O(n) and allocates fresh array each time * @return */ public byte[] getBases(); /** * Returns an array of the secondary bases in this pileup. Note this call costs O(n) and allocates fresh array each time * @return */ public byte[] getSecondaryBases(); /** * Returns an array of the quals in this pileup. Note this call costs O(n) and allocates fresh array each time * @return */ public byte[] getQuals(); /** * Get an array of the mapping qualities * @return */ public byte[] getMappingQuals(); }