本文整理了Java中org.broadinstitute.gatk.utils.sam.GATKSAMRecord.getReadGroup()
方法的一些代码示例,展示了GATKSAMRecord.getReadGroup()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GATKSAMRecord.getReadGroup()
方法的具体详情如下:
包路径:org.broadinstitute.gatk.utils.sam.GATKSAMRecord
类名称:GATKSAMRecord
方法名:getReadGroup
[英]Get the GATKSAMReadGroupRecord of this read
[中]获取此读取的GATKSAMReadGroupRecord
代码示例来源:origin: broadgsa/gatk
/**
* Efficient caching accessor that returns the GATK NGSPlatform of this read
* @return
*/
public NGSPlatform getNGSPlatform() {
return getReadGroup().getNGSPlatform();
}
代码示例来源:origin: broadgsa/gatk
/**
* Convenience get -- get the NGSPlatform from a GATKSAMRecord.
*
* Just gets the platform from the GATKReadGroupRecord associated with this read.
*
* @param read a non-null GATKSAMRecord
* @return an NGSPlatform object matching the PL field of the header, of UNKNOWN if there was no match,
* if there is no read group for read, or there's no PL field for the read group
*/
public static NGSPlatform fromRead(final GATKSAMRecord read) {
if ( read == null ) throw new IllegalArgumentException("read cannot be null");
final GATKSAMReadGroupRecord rg = read.getReadGroup();
return rg == null ? UNKNOWN : rg.getNGSPlatform();
}
代码示例来源:origin: broadgsa/gatk-protected
private boolean isReadFromNormal(final GATKSAMRecord rec) {
return normalSampleName != null && normalSampleName.equals(rec.getReadGroup().getSample());
}
代码示例来源:origin: broadgsa/gatk
/**
* checks if the read has a platform tag in the readgroup equal to 'name'.
* Assumes that 'name' is upper-cased.
*
* @param read the read to test
* @param name the upper-cased platform name to test
* @return whether or not name == PL tag in the read group of read
*/
public static boolean isPlatformRead(GATKSAMRecord read, String name) {
SAMReadGroupRecord readGroup = read.getReadGroup();
if (readGroup != null) {
Object readPlatformAttr = readGroup.getAttribute("PL");
if (readPlatformAttr != null)
return readPlatformAttr.toString().toUpperCase().contains(name);
}
return false;
}
代码示例来源:origin: broadgsa/gatk
public Collection<String> getSamples() {
if (pileupElementTracker instanceof PerSamplePileupElementTracker) {
PerSamplePileupElementTracker<PileupElement> tracker = (PerSamplePileupElementTracker<PileupElement>) pileupElementTracker;
return new HashSet<String>(tracker.getSamples());
} else {
Collection<String> sampleNames = new HashSet<String>();
for (PileupElement p : this) {
GATKSAMRecord read = p.getRead();
String sampleName = read.getReadGroup() != null ? read.getReadGroup().getSample() : null;
sampleNames.add(sampleName);
}
return sampleNames;
}
}
代码示例来源:origin: broadgsa/gatk
/**
* Gets a list of the read groups represented in this pileup.
*
* @return
*/
@Override
public Collection<String> getReadGroups() {
Set<String> readGroups = new HashSet<String>();
for (PileupElement pileupElement : this)
readGroups.add(pileupElement.getRead().getReadGroup().getReadGroupId());
return readGroups;
}
代码示例来源:origin: broadgsa/gatk-protected
public static Map<String, List<GATKSAMRecord>> splitReadsBySample( final SampleList samplesList, final Collection<GATKSAMRecord> reads ) {
final Map<String, List<GATKSAMRecord>> returnMap = new HashMap<>();
final int sampleCount = samplesList.sampleCount();
for (int i = 0; i < sampleCount; i++)
returnMap.put(samplesList.sampleAt(i), new ArrayList<GATKSAMRecord>());
for( final GATKSAMRecord read : reads )
returnMap.get(read.getReadGroup().getSample()).add(read);
return returnMap;
}
代码示例来源:origin: broadgsa/gatk
@Override
public Integer map(final ReferenceContext referenceContext,final GATKSAMRecord samRecord,final RefMetaDataTracker RefMetaDataTracker) {
final int length = Math.abs(samRecord.getReadLength());
final SAMReadGroupRecord rg = samRecord.getReadGroup();
increment(table,length, rg);
return null;
}
代码示例来源:origin: broadgsa/gatk-protected
private void removeReadsFromAllSamplesExcept(final String targetSample, final ActiveRegion activeRegion) {
final Set<GATKSAMRecord> readsToRemove = new LinkedHashSet<>();
for( final GATKSAMRecord rec : activeRegion.getReads() ) {
if( !rec.getReadGroup().getSample().equals(targetSample) ) {
readsToRemove.add(rec);
}
}
activeRegion.removeAll( readsToRemove );
}
代码示例来源:origin: broadgsa/gatk
public Integer map(ReferenceContext ref, GATKSAMRecord read, RefMetaDataTracker metaDataTracker) {
if ( ! newSampleName.equals(read.getReadGroup().getSample()) ) {
throw new IllegalStateException(String.format("Encountered read with the wrong sample name. Expected %s found %s",
newSampleName, read.getReadGroup().getSample()));
}
return 1;
}
代码示例来源:origin: broadgsa/gatk-protected
private Set<GATKSAMRecord> filterNonPassingReads( final ActiveRegion activeRegion ) {
final Set<GATKSAMRecord> readsToRemove = new LinkedHashSet<>();
for( final GATKSAMRecord rec : activeRegion.getReads() ) {
if( rec.getReadLength() < READ_LENGTH_FILTER_THRESHOLD || rec.getMappingQuality() < READ_QUALITY_FILTER_THRESHOLD || (!isBadMateFilterDisabled && BadMateFilter.hasBadMate(rec)) || (keepRG != null && !rec.getReadGroup().getId().equals(keepRG)) ) {
readsToRemove.add(rec);
}
}
activeRegion.removeAll( readsToRemove );
return readsToRemove;
}
代码示例来源:origin: broadgsa/gatk
@Override
public ReadBackedPileup getPileupForSample(String sampleName) {
if (pileupElementTracker instanceof PerSamplePileupElementTracker) {
PerSamplePileupElementTracker<PileupElement> tracker = (PerSamplePileupElementTracker<PileupElement>) pileupElementTracker;
PileupElementTracker<PileupElement> filteredElements = tracker.getElements(sampleName);
return filteredElements != null ? createNewPileup(loc, filteredElements) : null;
} else {
UnifiedPileupElementTracker<PileupElement> filteredTracker = new UnifiedPileupElementTracker<PileupElement>();
for (PileupElement p : pileupElementTracker) {
GATKSAMRecord read = p.getRead();
if (sampleName != null) {
if (read.getReadGroup() != null && sampleName.equals(read.getReadGroup().getSample()))
filteredTracker.add(p);
} else {
if (read.getReadGroup() == null || read.getReadGroup().getSample() == null)
filteredTracker.add(p);
}
}
return filteredTracker.size() > 0 ? createNewPileup(loc, filteredTracker) : null;
}
}
代码示例来源:origin: broadgsa/gatk
@Override
public void recordValues(final GATKSAMRecord read, final ReadCovariates values) {
final String readGroupId = readGroupValueFromRG(read.getReadGroup());
final int key = keyForReadGroup(readGroupId);
final int l = read.getReadLength();
for (int i = 0; i < l; i++)
values.addCovariate(key, key, key, i);
}
代码示例来源:origin: broadgsa/gatk-protected
protected Set<GATKSAMRecord> filterNonPassingReads( final ActiveRegion activeRegion) {
final Set<GATKSAMRecord> readsToRemove = new LinkedHashSet<>();
for( final GATKSAMRecord rec : activeRegion.getReads() ) {
//TODO: Takuto points out that this is questionable. Let's think hard abut it.
// KCIBUL: only perform read quality filtering on tumor reads...
if (isReadFromNormal(rec)) {
if( rec.getReadLength() < MIN_READ_LENGTH ) {
readsToRemove.add(rec);
}
} else if( rec.getReadLength() < MIN_READ_LENGTH || rec.getMappingQuality() < MQthreshold || BadMateFilter.hasBadMate(rec) ||
(keepRG != null && !rec.getReadGroup().getId().equals(keepRG)) ) {
readsToRemove.add(rec);
}
}
activeRegion.removeAll(readsToRemove);
return readsToRemove;
}
代码示例来源:origin: broadgsa/gatk
@Override
public Integer map(ReferenceContext referenceContext, GATKSAMRecord read, RefMetaDataTracker RefMetaDataTracker) {
final String rgID = read.getReadGroup().getId();
final PerReadGroupInfo info = readGroupInfo.get(rgID);
if ( info.needsMoreData() ) {
info.readLength.add(read.getReadLength());
info.nReadsSeen++;
if ( read.getReadPairedFlag() ) {
info.nReadsPaired++;
if ( read.getInferredInsertSize() != 0) {
info.insertSize.add(Math.abs(read.getInferredInsertSize()));
}
}
}
return null;
}
代码示例来源:origin: broadgsa/gatk
@Test(enabled = !DEBUG, dataProvider = "MergeFragmentsTest")
public void testMergingTwoReads(final String name, final GATKSAMRecord read1, final GATKSAMRecord read2, final GATKSAMRecord expectedMerged) {
final GATKSAMRecord actual = FragmentUtils.mergeOverlappingPairedFragments(read1, read2);
if ( expectedMerged == null ) {
Assert.assertNull(actual, "Expected reads not to merge, but got non-null result from merging");
} else {
Assert.assertTrue(actual.isStrandless(), "Merged reads should be strandless");
Assert.assertNotNull(actual, "Expected reads to merge, but got null result from merging");
// I really care about the bases, the quals, the CIGAR, and the read group tag
Assert.assertEquals(actual.getCigarString(), expectedMerged.getCigarString());
Assert.assertEquals(actual.getReadBases(), expectedMerged.getReadBases());
Assert.assertEquals(actual.getReadGroup(), expectedMerged.getReadGroup());
Assert.assertEquals(actual.getMappingQuality(), expectedMerged.getMappingQuality());
for ( final EventType type : EventType.values() )
Assert.assertEquals(actual.getBaseQualities(type), expectedMerged.getBaseQualities(type), "Failed base qualities for event type " + type);
}
}
代码示例来源:origin: broadgsa/gatk
/**
* Clears all attributes except ReadGroup of the read.
*/
public GATKSAMRecord simplify () {
GATKSAMReadGroupRecord rg = getReadGroup(); // save the read group information
byte[] insQuals = (this.getAttribute(BQSR_BASE_INSERTION_QUALITIES) == null) ? null : getBaseInsertionQualities();
byte[] delQuals = (this.getAttribute(BQSR_BASE_DELETION_QUALITIES) == null) ? null : getBaseDeletionQualities();
this.clearAttributes(); // clear all attributes from the read
this.setReadGroup(rg); // restore read group
if (insQuals != null)
this.setBaseQualities(insQuals, EventType.BASE_INSERTION); // restore base insertion if we had any
if (delQuals != null)
this.setBaseQualities(delQuals, EventType.BASE_DELETION); // restore base deletion if we had any
return this;
}
代码示例来源:origin: broadgsa/gatk
@Test(enabled = true)
public void testMaxCyclePasses() {
int readLength = RAC.MAXIMUM_CYCLE_VALUE;
GATKSAMRecord read = ReadUtils.createRandomRead(readLength);
read.setReadPairedFlag(true);
read.setReadGroup(new GATKSAMReadGroupRecord("MY.ID"));
read.getReadGroup().setPlatform("illumina");
ReadCovariates readCovariates = new ReadCovariates(read.getReadLength(), 1);
covariate.recordValues(read, readCovariates);
}
}
代码示例来源:origin: broadgsa/gatk
@Test(enabled = true, expectedExceptions={UserException.class})
public void testMoreThanMaxCycleFails() {
int readLength = RAC.MAXIMUM_CYCLE_VALUE + 1;
GATKSAMRecord read = ReadUtils.createRandomRead(readLength);
read.setReadPairedFlag(true);
read.setReadGroup(new GATKSAMReadGroupRecord("MY.ID"));
read.getReadGroup().setPlatform("illumina");
ReadCovariates readCovariates = new ReadCovariates(read.getReadLength(), 1);
covariate.recordValues(read, readCovariates);
}
代码示例来源:origin: broadgsa/gatk
@Test(enabled = true)
public void testSimpleCycles() {
short readLength = 10;
GATKSAMRecord read = ReadUtils.createRandomRead(readLength);
read.setReadPairedFlag(true);
read.setReadGroup(new GATKSAMReadGroupRecord("MY.ID"));
read.getReadGroup().setPlatform("illumina");
ReadCovariates readCovariates = new ReadCovariates(read.getReadLength(), 1);
covariate.recordValues(read, readCovariates);
verifyCovariateArray(readCovariates.getMismatchesKeySet(), 1, (short) 1);
read.setReadNegativeStrandFlag(true);
covariate.recordValues(read, readCovariates);
verifyCovariateArray(readCovariates.getMismatchesKeySet(), readLength, -1);
read.setSecondOfPairFlag(true);
covariate.recordValues(read, readCovariates);
verifyCovariateArray(readCovariates.getMismatchesKeySet(), -readLength, 1);
read.setReadNegativeStrandFlag(false);
covariate.recordValues(read, readCovariates);
verifyCovariateArray(readCovariates.getMismatchesKeySet(), -1, -1);
}
内容来源于网络,如有侵权,请联系作者删除!