本文整理汇总了Java中htsjdk.samtools.SAMRecord.setAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java SAMRecord.setAttribute方法的具体用法?Java SAMRecord.setAttribute怎么用?Java SAMRecord.setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.samtools.SAMRecord
的用法示例。
在下文中一共展示了SAMRecord.setAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseTag
import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
private void parseTag(final SAMRecord samRecord, final String tag) {
Map.Entry<String, Object> entry = null;
try {
entry = tagCodec.decode(tag);
} catch (SAMFormatException e) {
e.printStackTrace();
}
if (entry != null) {
if (entry.getValue() instanceof TagValueAndUnsignedArrayFlag) {
final TagValueAndUnsignedArrayFlag valueAndFlag =
(TagValueAndUnsignedArrayFlag) entry.getValue();
if (valueAndFlag.isUnsignedArray) {
samRecord.setUnsignedArrayAttribute(entry.getKey(),
valueAndFlag.value);
} else {
samRecord.setAttribute(entry.getKey(), valueAndFlag.value);
}
} else {
samRecord.setAttribute(entry.getKey(), entry.getValue());
}
}
}
示例2: baqRead
import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
/**
* Modifies read in place so that the base quality scores are capped by the BAQ calculation. Uses the BAQ
* tag if present already and alwaysRecalculate is false, otherwise fires up the HMM and does the BAQ on the fly
* using the refReader to obtain the reference bases as needed.
*
* @param read
* @param refContentProvider
* @param calculationType
* @return BQ qualities for use, in case qmode is DONT_MODIFY
*/
public byte[] baqRead(SAMRecord read, RefContentProvider refContentProvider, CalculationMode calculationType, QualityMode qmode ) {
if ( DEBUG ) System.out.printf("BAQ %s read %s%n", calculationType, read.getReadName());
byte[] BAQQuals = read.getBaseQualities(); // in general we are overwriting quals, so just get a pointer to them
if ( calculationType == CalculationMode.OFF) { // we don't want to do anything
; // just fall though
} else if ( excludeReadFromBAQ(read) ) {
; // just fall through
} else {
final boolean readHasBAQTag = hasBAQTag(read);
if ( calculationType == CalculationMode.RECALCULATE || ! readHasBAQTag ) {
if ( DEBUG ) System.out.printf(" Calculating BAQ on the fly%n");
BAQCalculationResult hmmResult = calcBAQFromHMM(read, refContentProvider);
if ( hmmResult != null ) {
switch ( qmode ) {
case ADD_TAG: addBAQTag(read, hmmResult.bq); break;
case OVERWRITE_QUALS: System.arraycopy(hmmResult.bq, 0, read.getBaseQualities(), 0, hmmResult.bq.length); break;
case DONT_MODIFY: BAQQuals = hmmResult.bq; break;
default: throw new ReviewedGATKException("BUG: unexpected qmode " + qmode);
}
} else if ( readHasBAQTag ) {
// remove the BAQ tag if it's there because we cannot trust it
read.setAttribute(BAQ_TAG, null);
}
} else if ( qmode == QualityMode.OVERWRITE_QUALS ) { // only makes sense if we are overwriting quals
if ( DEBUG ) System.out.printf(" Taking BAQ from tag%n");
// this overwrites the original qualities
calcBAQFromTag(read, true, false);
}
}
return BAQQuals;
}
示例3: addBAQTag
import htsjdk.samtools.SAMRecord; //导入方法依赖的package包/类
public static void addBAQTag(SAMRecord read, byte[] baq) {
read.setAttribute(BAQ_TAG, encodeBQTag(read, baq));
}