src/main/java/org/ncgr/gwas/VCFLoader.java
public static void main(String[] args) {
        if (args.length==0 || args.length>2) {
            System.out.println("Usage VCFLoader <vcf-file> [allrecords]");
            System.exit(0);
        }

        String vcfFilename = args[0];
        // default is to output only SNP records
        boolean allRecords = false;
        if (args.length>1) {
            allRecords = Boolean.parseBoolean(args[1]);
        }
        
        VCFLoader loader = new VCFLoader(vcfFilename);
        loader.load();

        for (VariantContext vc : loader.vcList) {
            if (allRecords || vc.isSNP()) {
                // values
                String id = vc.getID();
                String source = vc.getSource();
                String contig = vc.getContig();
                List<String> sampleNames = vc.getSampleNamesOrderedByName();
                int start = vc.getStart();
                Allele ref = vc.getReference();
                List<Allele> alts = vc.getAlternateAlleles();
                List<Integer> dp4List = vc.getAttributeAsIntList("DP4", 0);
                // output
                String altString = "";
                for (Allele alt : alts) {
                    if (altString.length()>0) altString += ",";
                    altString += alt.getBaseString();
                }                
                System.out.println(contig+"\t"+start+"\t"+ref.getBaseString()+"\t"+altString+"\t"+dp4List.get(0)+"\t"+dp4List.get(1)+"\t"+dp4List.get(2)+"\t"+dp4List.get(3));
            }
        }
    }
/**
     * Main class outputs a tab-delimited remix of a VCF file. Specify whether you want SNPs only.
     */
Main class outputs a tab-delimited remix of a VCF file. Specify whether you want SNPs only.
Main class outputs a tab - delimited remix of a VCF file . Specify whether you want SNPs only .
public static void main(String[] args) {
        if (args.length==0 || args.length>2) {
            System.out.println("Usage VCFLoader <vcf-file> [allrecords]");
            System.exit(0);
        }
        String vcfFilename = args[0];
        boolean allRecords = false;
        if (args.length>1) {
            allRecords = Boolean.parseBoolean(args[1]);
        }
        VCFLoader loader = new VCFLoader(vcfFilename);
        loader.load();
        for (VariantContext vc : loader.vcList) {
            if (allRecords || vc.isSNP()) {
                String id = vc.getID();
                String source = vc.getSource();
                String contig = vc.getContig();
                List<String> sampleNames = vc.getSampleNamesOrderedByName();
                int start = vc.getStart();
                Allele ref = vc.getReference();
                List<Allele> alts = vc.getAlternateAlleles();
                List<Integer> dp4List = vc.getAttributeAsIntList("DP4", 0);
                String altString = "";
                for (Allele alt : alts) {
                    if (altString.length()>0) altString += ",";
                    altString += alt.getBaseString();
                }                
                System.out.println(contig+"\t"+start+"\t"+ref.getBaseString()+"\t"+altString+"\t"+dp4List.get(0)+"\t"+dp4List.get(1)+"\t"+dp4List.get(2)+"\t"+dp4List.get(3));
            }
        }
    }
public static void main ( String [ ] args ) { if ( args . length == 0 || args . length > 2 ) { System . out . println ( "Usage VCFLoader <vcf-file> [allrecords]" ) ; System . exit ( 0 ) ; } String vcfFilename = args [ 0 ] ; boolean allRecords = false ; if ( args . length > 1 ) { allRecords = Boolean . parseBoolean ( args [ 1 ] ) ; } VCFLoader loader = new VCFLoader ( vcfFilename ) ; loader . load ( ) ; for ( VariantContext vc : loader . vcList ) { if ( allRecords || vc . isSNP ( ) ) { String id = vc . getID ( ) ; String source = vc . getSource ( ) ; String contig = vc . getContig ( ) ; List < String > sampleNames = vc . getSampleNamesOrderedByName ( ) ; int start = vc . getStart ( ) ; Allele ref = vc . getReference ( ) ; List < Allele > alts = vc . getAlternateAlleles ( ) ; List < Integer > dp4List = vc . getAttributeAsIntList ( "DP4" , 0 ) ; String altString = "" ; for ( Allele alt : alts ) { if ( altString . length ( ) > 0 ) altString += "," ; altString += alt . getBaseString ( ) ; } System . out . println ( contig + "\t" + start + "\t" + ref . getBaseString ( ) + "\t" + altString + "\t" + dp4List . get ( 0 ) + "\t" + dp4List . get ( 1 ) + "\t" + dp4List . get ( 2 ) + "\t" + dp4List . get ( 3 ) ) ; } } }
Main class outputs a tab-delimited remix of a VCF file.
Main class outputs a tab - delimited remix of a VCF file .
// default is to output only SNP records // values // output