本文整理汇总了Java中htsjdk.variant.vcf.VCFHeaderVersion.toHeaderVersion方法的典型用法代码示例。如果您正苦于以下问题:Java VCFHeaderVersion.toHeaderVersion方法的具体用法?Java VCFHeaderVersion.toHeaderVersion怎么用?Java VCFHeaderVersion.toHeaderVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.variant.vcf.VCFHeaderVersion
的用法示例。
在下文中一共展示了VCFHeaderVersion.toHeaderVersion方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readActualHeader
import htsjdk.variant.vcf.VCFHeaderVersion; //导入方法依赖的package包/类
/**
* Reads all of the header from the provided iterator, but no reads no further.
* @param lineIterator the line reader to take header lines from
* @return The parsed header
*/
@SuppressWarnings("static-access")
@Override
public Object readActualHeader(final LineIterator lineIterator) {
final List<String> headerStrings = new ArrayList<String>();
String line;
boolean foundHeaderVersion = false;
while (lineIterator.hasNext()) {
line = lineIterator.peek();
lineNo++;
if (line.startsWith(VCFHeader.METADATA_INDICATOR)) {
final String[] lineFields = line.substring(2).split("=");
if (lineFields.length == 2 && VCFHeaderVersion.isFormatString(lineFields[0]) ) {
if ( !VCFHeaderVersion.isVersionString(lineFields[1]) )
throw new TribbleException.InvalidHeader(lineFields[1] + " is not a supported version");
foundHeaderVersion = true;
version = VCFHeaderVersion.toHeaderVersion(lineFields[1]);
if ( ! version.isAtLeastAsRecentAs(VCFHeaderVersion.VCF4_0) )
throw new TribbleException.InvalidHeader("This codec is strictly for VCFv4; please use the VCF3 codec for " + lineFields[1]);
if ( version != VCFHeaderVersion.VCF4_0 && version != VCFHeaderVersion.VCF4_1 && version != VCFHeaderVersion.VCF4_2 )
throw new TribbleException.InvalidHeader("This codec is strictly for VCFv4 and does not support " + lineFields[1]);
}
headerStrings.add(lineIterator.next());
}
else if (line.startsWith(VCFHeader.HEADER_INDICATOR)) {
if (!foundHeaderVersion) {
throw new TribbleException.InvalidHeader("We never saw a header line specifying VCF version");
}
headerStrings.add(lineIterator.next());
super.parseHeaderFromLines(headerStrings, version);
return this.header;
}
else {
throw new TribbleException.InvalidHeader("We never saw the required CHROM header line (starting with one #) for the input VCF file");
}
}
throw new TribbleException.InvalidHeader("We never saw the required CHROM header line (starting with one #) for the input VCF file");
}
示例2: getVCFHeaderVersion
import htsjdk.variant.vcf.VCFHeaderVersion; //导入方法依赖的package包/类
public static VCFHeaderVersion getVCFHeaderVersion(VCFHeader vcfHeader){
Iterator<VCFHeaderLine> iter = vcfHeader.getMetaDataInInputOrder().iterator();
while(iter.hasNext()){
VCFHeaderLine hl = iter.next();
if(hl.getKey().equals("fileformat")){
return VCFHeaderVersion.toHeaderVersion(hl.getValue());
}
}
return null;
}
示例3: setHeader
import htsjdk.variant.vcf.VCFHeaderVersion; //导入方法依赖的package包/类
@Override public void setHeader(VCFHeader header) {
VCFHeaderVersion version = null;
// Normally AbstractVCFCodec parses the header and thereby sets the
// version field. It gets used later on so we need to set it.
for (final VCFHeaderLine line : header.getMetaDataInInputOrder()) {
if (VCFHeaderVersion.isFormatString(line.getKey())) {
version = VCFHeaderVersion.toHeaderVersion(line.getValue());
break;
}
}
codec.setHeaderAndVersion(header, version);
}
示例4: warpHeader
import htsjdk.variant.vcf.VCFHeaderVersion; //导入方法依赖的package包/类
private static VCFHeader warpHeader(VCFHeader in, Map<String, Long> namesAndLength)
throws IllegalArgumentException {
Set<VCFHeaderLine> newLines = new HashSet<>();
boolean hasSource = false;
VCFHeaderVersion version = DEFAULT_VCF_VERSION;
for (VCFHeaderLine line : in.getMetaDataInInputOrder()) {
if (line.getKey().equals("reference")) {
newLines.add(new VCFHeaderLine(line.getKey(), ARGS.refTargetFASTA));
} else if (line.getKey().equals("source")) {
newLines.add(new VCFHeaderLine(line.getKey(), line.getValue() + "_and_"
+ GENOME_WARP_VERSION));
hasSource = true;
} else if (line.getKey().equals("fileformat")) {
version = VCFHeaderVersion.toHeaderVersion(line.getValue());
if (version == null) {
throw new IllegalArgumentException("malformed version: " + line.getValue());
}
} else if (line.getKey().equals(VCFConstants.CONTIG_HEADER_KEY)) {
continue;
} else {
newLines.add(line);
}
}
if (!hasSource) {
newLines.add(new VCFHeaderLine("source", GENOME_WARP_VERSION));
}
// Add contigs
int i = 0;
for (Map.Entry<String, Long> entry : namesAndLength.entrySet()) {
String currName = entry.getKey();
long chrSize = entry.getValue();
newLines.add(new VCFContigHeaderLine(VCFHeaderLine.toStringEncoding(
createContigEntry(currName, chrSize, ARGS.targetAssembly, ARGS.species)),
version, VCFConstants.CONTIG_HEADER_KEY, i++));
}
return new VCFHeader(newLines, in.getSampleNamesInOrder());
}