lindenb / jvarkit

Java utilities for Bioinformatics
https://jvarkit.readthedocs.io/
Other
482 stars 133 forks source link

Adding INFO data in bioalcidaejdk.jar result #196

Open se2cheeese opened 2 years ago

se2cheeese commented 2 years ago

Hello. I found your bioalcidaejdk.jar very useful to make a table that summarizes the numbers of homozygous and heterozygous non-reference from a multi-sample VCF file.

I used the following code to follow your instruction. java -jar /gpfs/group/torkamani/salee/Tools/jvarkit/dist/bioalcidaejdk.jar -e 'final List<GenotypeType> all_types = Arrays.asList(GenotypeType.values());println("CHROM\tPOS\tREF\tALT\t"+all_types.stream().map(T->"count."+T.name()+"\tsample."+T.name()).collect(Collectors.joining("\t")));stream().forEach(V->println( V.getContig()+"\t"+ V.getStart()+"\t"+ V.getReference().getDisplayString()+"\t"+ V.getAlternateAlleles().stream().map(A->A.getDisplayString()).collect(Collectors.joining(","))+"\t"+ all_types.stream().map(T-> String.valueOf( V.getGenotypes().stream(). filter(G->G.getType().equals(T)). count()) + "\t"+ V.getGenotypes().stream(). filter(G->G.getType().equals(T)). map(G->G.getSampleName()). collect(Collectors.joining(",")) ). collect(Collectors.joining("\t"))) );' $INPUT > $OUTPUT

I wonder whether it is possible to add INFO's in vcf to the final result? For example, I would like to add Gene.refGene to the final result below.

CHROM POS REF ALT Gene.refGene count.NO_CALL sample.NO_CALL count.HOM_REF ...

Would it be possible?

Thank you in advance.

lindenb commented 2 years ago

have a look at V.getAttribute* in https://samtools.github.io/htsjdk/javadoc/htsjdk/htsjdk/variant/variantcontext/VariantContext.html