Search in sources :

Example 6 with VCFContigHeaderLine

use of htsjdk.variant.vcf.VCFContigHeaderLine in project jvarkit by lindenb.

the class VCFUtils method samSequenceDictToVCFContigHeaderLine.

public static SortedSet<VCFContigHeaderLine> samSequenceDictToVCFContigHeaderLine(SAMSequenceDictionary dict) {
    SortedSet<VCFContigHeaderLine> meta2 = new TreeSet<VCFContigHeaderLine>();
    for (SAMSequenceRecord ssr : dict.getSequences()) {
        Map<String, String> mapping = new HashMap<String, String>();
        mapping.put("ID", ssr.getSequenceName());
        mapping.put("length", String.valueOf(ssr.getSequenceLength()));
        String as = ssr.getAssembly();
        if (as != null && !as.trim().isEmpty())
            mapping.put("assembly", as);
        VCFContigHeaderLine h = new VCFContigHeaderLine(mapping, ssr.getSequenceIndex());
        meta2.add(h);
    }
    return meta2;
}
Also used : HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) SAMSequenceRecord(htsjdk.samtools.SAMSequenceRecord) VCFContigHeaderLine(htsjdk.variant.vcf.VCFContigHeaderLine)

Aggregations

VCFContigHeaderLine (htsjdk.variant.vcf.VCFContigHeaderLine)6 VCFHeaderLine (htsjdk.variant.vcf.VCFHeaderLine)5 HashMap (java.util.HashMap)3 SAMSequenceRecord (htsjdk.samtools.SAMSequenceRecord)2 Genotype (htsjdk.variant.variantcontext.Genotype)2 GenotypeBuilder (htsjdk.variant.variantcontext.GenotypeBuilder)2 VariantContextBuilder (htsjdk.variant.variantcontext.VariantContextBuilder)2 VCFFormatHeaderLine (htsjdk.variant.vcf.VCFFormatHeaderLine)2 VCFHeader (htsjdk.variant.vcf.VCFHeader)2 VCFInfoHeaderLine (htsjdk.variant.vcf.VCFInfoHeaderLine)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 TreeSet (java.util.TreeSet)2 Counter (com.github.lindenb.jvarkit.util.Counter)1 SAMSequenceDictionaryProgress (com.github.lindenb.jvarkit.util.picard.SAMSequenceDictionaryProgress)1 LineIterator (htsjdk.tribble.readers.LineIterator)1 Allele (htsjdk.variant.variantcontext.Allele)1 VariantContext (htsjdk.variant.variantcontext.VariantContext)1 VariantContextWriter (htsjdk.variant.variantcontext.writer.VariantContextWriter)1 BufferedReader (java.io.BufferedReader)1