本文整理了Java中org.broadinstitute.gatk.utils.sam.GATKSAMRecord.setAttribute()
方法的一些代码示例,展示了GATKSAMRecord.setAttribute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GATKSAMRecord.setAttribute()
方法的具体详情如下:
包路径:org.broadinstitute.gatk.utils.sam.GATKSAMRecord
类名称:GATKSAMRecord
方法名:setAttribute
暂无
代码示例来源:origin: broadgsa/gatk
public void setReadGroup( final GATKSAMReadGroupRecord readGroup ) {
mReadGroup = readGroup;
retrievedReadGroup = true;
setAttribute("RG", mReadGroup.getId()); // todo -- this should be standardized, but we don't have access to SAMTagUtils!
}
代码示例来源:origin: broadgsa/gatk-protected
/**
* Add reads that have been dropped for the specified reason to the dropped list.
*/
public void addReads(final Reason reason, final Collection<GATKSAMRecord> reads) {
Set<GATKSAMRecord> readsForReason = droppedReads.get(reason);
if (null == readsForReason) {
readsForReason = new HashSet<>(reads.size());
}
for (final GATKSAMRecord rec: reads) {
if (!previouslyDropped(rec)) {
// tag the original read so we can track the ones we've already seen and
// only add them to the dropped list once
rec.setAttribute(SAMTag.FT.name(), reason.reasonName());
readsForReason.add(rec);
}
}
droppedReads.put(reason, readsForReason);
}
代码示例来源:origin: broadgsa/gatk
/**
* Setters and Accessors for base insertion and base deletion quality scores
*/
public void setBaseQualities( final byte[] quals, final EventType errorModel ) {
switch( errorModel ) {
case BASE_SUBSTITUTION:
setBaseQualities(quals);
break;
case BASE_INSERTION:
setAttribute( GATKSAMRecord.BQSR_BASE_INSERTION_QUALITIES, quals == null ? null : SAMUtils.phredToFastq(quals) );
break;
case BASE_DELETION:
setAttribute( GATKSAMRecord.BQSR_BASE_DELETION_QUALITIES, quals == null ? null : SAMUtils.phredToFastq(quals) );
break;
default:
throw new ReviewedGATKException("Unrecognized Base Recalibration type: " + errorModel );
}
}
代码示例来源:origin: broadgsa/gatk
public boolean finalizeUpdate() {
// if we haven't made any changes, don't do anything
if ( newCigar == null )
return false;
if ( newStart == -1 )
newStart = read.getAlignmentStart();
else if ( Math.abs(newStart - read.getAlignmentStart()) > MAX_POS_MOVE_ALLOWED ) {
logger.debug(String.format("Attempting to realign read %s at %d more than %d bases to %d.", read.getReadName(), read.getAlignmentStart(), MAX_POS_MOVE_ALLOWED, newStart));
return false;
}
// store the old CIGAR and start in case we need to back out
final Cigar oldCigar = read.getCigar();
final int oldStart = read.getAlignmentStart();
// try updating the read with the new CIGAR and start
read.setCigar(newCigar);
read.setAlignmentStart(newStart);
// back out if necessary
if ( realignmentProducesBadAlignment(read) ) {
read.setCigar(oldCigar);
read.setAlignmentStart(oldStart);
return false;
}
// annotate the record with the original cigar and start (if it changed)
if ( !NO_ORIGINAL_ALIGNMENT_TAGS ) {
read.setAttribute(ORIGINAL_CIGAR_TAG, oldCigar.toString());
if ( newStart != oldStart )
read.setAttribute(ORIGINAL_POSITION_TAG, oldStart);
}
return true;
}
代码示例来源:origin: broadgsa/gatk
private GATKSAMRecord makeRead() {
final SAMReadGroupRecord rg = header.getReadGroups().get(0);
final String readName = String.format("%s.%d.%s", "read", readI, rg.getId());
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, readName, 0, 1, readLength);
read.setReadGroup(new GATKSAMReadGroupRecord(rg));
if ( payloadInBytes > 0 )
// add a payload byte array to push memory use per read even higher
read.setAttribute("PL", new byte[payloadInBytes]);
return read;
}
}
代码示例来源:origin: broadgsa/gatk
read.setAttribute(SAMTag.NM.name(), SequenceUtil.calculateSamNmTag(read, reference, leftmostIndex - 1));
if ( read.getAttribute(SAMTag.UQ.name()) != null )
read.setAttribute(SAMTag.UQ.name(), SequenceUtil.sumQualitiesOfMismatches(read, reference, leftmostIndex-1));
} catch (Exception e) {
read.setAttribute(SAMTag.MD.name(), null);
代码示例来源:origin: broadgsa/gatk
@Test()
public void testPLFromReadWithRGButNoPL() {
final SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(seq.getSequenceDictionary());
final String rgID = "ID";
final SAMReadGroupRecord rg = new SAMReadGroupRecord(rgID);
header.addReadGroup(rg);
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "myRead", 0, 1, 10);
read.setAttribute("RG", rgID);
Assert.assertEquals(NGSPlatform.fromRead(read), NGSPlatform.UNKNOWN);
}
代码示例来源:origin: broadgsa/gatk
read1.setAttribute("RG",readGroupOne.getId());
GATKSAMRecord read2 = ArtificialSAMUtils.createArtificialRead(header,"read2",0,1,10);
read2.setAttribute("RG",readGroupTwo.getId());
GATKSAMRecord read3 = ArtificialSAMUtils.createArtificialRead(header,"read3",0,1,10);
read3.setAttribute("RG",readGroupOne.getId());
GATKSAMRecord read4 = ArtificialSAMUtils.createArtificialRead(header,"read4",0,1,10);
read4.setAttribute("RG",readGroupTwo.getId());
GATKSAMRecord read5 = ArtificialSAMUtils.createArtificialRead(header,"read5",0,1,10);
read5.setAttribute("RG",readGroupTwo.getId());
GATKSAMRecord read6 = ArtificialSAMUtils.createArtificialRead(header,"read6",0,1,10);
read6.setAttribute("RG",readGroupOne.getId());
GATKSAMRecord read7 = ArtificialSAMUtils.createArtificialRead(header,"read7",0,1,10);
read7.setAttribute("RG",readGroupOne.getId());
代码示例来源:origin: broadgsa/gatk
/**
* A unit test that creates an artificial read for testing some code that uses reads
*/
@Test(dataProvider = "TestMappings")
public void testPLFromReadWithRG(final String plField, final NGSPlatform expected) {
final SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(seq.getSequenceDictionary());
final String rgID = "ID";
final SAMReadGroupRecord rg = new SAMReadGroupRecord(rgID);
if ( plField != null )
rg.setPlatform(plField);
header.addReadGroup(rg);
final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "myRead", 0, 1, 10);
read.setAttribute("RG", rgID);
Assert.assertEquals(NGSPlatform.fromRead(read), expected);
}
代码示例来源:origin: broadgsa/gatk
@Test
public void testGetPileupForSample() {
String sample1 = "sample1";
String sample2 = "sample2";
SAMReadGroupRecord readGroupOne = new SAMReadGroupRecord("rg1");
readGroupOne.setSample(sample1);
SAMReadGroupRecord readGroupTwo = new SAMReadGroupRecord("rg2");
readGroupTwo.setSample(sample2);
SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(1,1,1000);
header.addReadGroup(readGroupOne);
header.addReadGroup(readGroupTwo);
GATKSAMRecord read1 = ArtificialSAMUtils.createArtificialRead(header,"read1",0,1,10);
read1.setAttribute("RG",readGroupOne.getId());
GATKSAMRecord read2 = ArtificialSAMUtils.createArtificialRead(header,"read2",0,1,10);
read2.setAttribute("RG",readGroupTwo.getId());
Map<String,ReadBackedPileupImpl> sampleToPileupMap = new HashMap<String,ReadBackedPileupImpl>();
sampleToPileupMap.put(sample1,new ReadBackedPileupImpl(null,Collections.singletonList(read1),0));
sampleToPileupMap.put(sample2,new ReadBackedPileupImpl(null,Collections.singletonList(read2),0));
ReadBackedPileup pileup = new ReadBackedPileupImpl(null,sampleToPileupMap);
ReadBackedPileup sample2Pileup = pileup.getPileupForSample(sample2);
Assert.assertEquals(sample2Pileup.getNumberOfElements(),1,"Sample 2 pileup has wrong number of elements");
Assert.assertEquals(sample2Pileup.getReads().get(0),read2,"Sample 2 pileup has incorrect read");
ReadBackedPileup missingSamplePileup = pileup.getPileupForSample("missing");
Assert.assertNull(missingSamplePileup,"Pileup for sample 'missing' should be null but isn't");
missingSamplePileup = pileup.getPileupForSample("not here");
Assert.assertNull(missingSamplePileup,"Pileup for sample 'not here' should be null but isn't");
}
代码示例来源:origin: broadgsa/gatk
read1.setAttribute("RG",readGroupOne.getId());
GATKSAMRecord read2 = ArtificialSAMUtils.createArtificialRead(header,"read2",0,1,10);
read2.setAttribute("RG",readGroupTwo.getId());
GATKSAMRecord read3 = ArtificialSAMUtils.createArtificialRead(header,"read3",0,1,10);
read3.setAttribute("RG",readGroupOne.getId());
GATKSAMRecord read4 = ArtificialSAMUtils.createArtificialRead(header,"read4",0,1,10);
read4.setAttribute("RG",readGroupTwo.getId());
代码示例来源:origin: broadgsa/gatk
prevBase = readBases[i];
read.setAttribute(RecalUtils.COLOR_SPACE_INCONSISTENCY_TAG, inconsistency);
代码示例来源:origin: broadgsa/gatk-protected
/**
* Write out a representation of this haplotype as a read
*
* @param haplotype a haplotype to write out. Cannot be null
* @param paddedRefLoc the reference location. Cannot be null
* @param isAmongBestHaplotypes true if among the best haplotypes, false if it was just one possible but not so good
*/
private void writeHaplotype(final Haplotype haplotype,
final GenomeLoc paddedRefLoc,
final boolean isAmongBestHaplotypes) {
final GATKSAMRecord record = new GATKSAMRecord(output.getHeader());
record.setReadBases(haplotype.getBases());
record.setAlignmentStart(paddedRefLoc.getStart() + haplotype.getAlignmentStartHapwrtRef());
record.setBaseQualities(Utils.dupBytes((byte) '!', haplotype.getBases().length));
record.setCigar(AlignmentUtils.consolidateCigar(haplotype.getCigar()));
record.setMappingQuality(isAmongBestHaplotypes ? 60 : 0);
record.setReadName("HC" + uniqueNameCounter++);
record.setAttribute(AlignmentUtils.HAPLOTYPE_TAG,haplotype.hashCode());
record.setReadUnmappedFlag(false);
record.setReferenceIndex(paddedRefLoc.getContigIndex());
record.setAttribute(SAMTag.RG.toString(), READ_GROUP_ID);
record.setFlags(16);
output.add(record);
}
代码示例来源:origin: broadgsa/gatk
read.setAttribute(HAPLOTYPE_TAG, haplotype.hashCode());
代码示例来源:origin: broadgsa/gatk-protected
/**
* Creates and writes an artificial read given the appropriate data
*
* @param readBases the bases
* @param contig the contig
* @param start the read start
* @param cigar the cigar string
* @param sample the sample name (used to get the right read group)
* @param isNegStrand should this read be on the negative strand?
*/
private void writeRead(final byte[] readBases, final String contig, final int start,
final String cigar, final String sample, final boolean isNegStrand) {
final GATKSAMRecord read = new GATKSAMRecord(header);
read.setBaseQualities(readQuals);
read.setReadBases(readBases);
read.setReadName("" + readNameCounter++);
read.setCigarString(cigar);
read.setReadPairedFlag(false);
read.setAlignmentStart(start);
read.setMappingQuality(60);
read.setReferenceName(contig);
read.setReadNegativeStrandFlag(isNegStrand);
read.setAttribute("RG", sampleRG(sample).getReadGroupId());
readWriter.addAlignment(read);
}
代码示例来源:origin: broadgsa/gatk
if (emitOriginalQuals && read.getAttribute(SAMTag.OQ.name()) == null) { // Save the old qualities if the tag isn't already taken in the read
try {
read.setAttribute(SAMTag.OQ.name(), SAMUtils.phredToFastq(read.getBaseQualities()));
} catch (IllegalArgumentException e) {
throw new UserException.MalformedBAM(read, "illegal base quality encountered; " + e.getMessage());
内容来源于网络,如有侵权,请联系作者删除!