b1c2fdec9a31078a56333427830a760757d22a51 angie Fri Jun 17 14:44:44 2016 -0700 Command line wrapper script for hgVai: hg/utils/vai.pl . hgVai has a new input parameter to specify a local file of variants instead of a custom track, and inhibits web output (e.g. Content-Type and cookies) when run on the command line. Added support for reading pgSnp variants from input file without bin column instead of database (pgSnp.as includes bin, but pgSnp files do not). Has been tested somewhat on GBiB. Needs documentation. refs #12216 diff --git src/hg/lib/variant.c src/hg/lib/variant.c index c1ddf93..2270896 100644 --- src/hg/lib/variant.c +++ src/hg/lib/variant.c @@ -106,35 +106,48 @@ // we have a new allele! struct allele *allele; lmAllocVar(lm, allele); slAddHead(&variant->alleles, allele); allele->variant = variant; allele->length = alleleStringLength; allele->sequence = lmCloneString(lm, thisAlleleString); allele->isReference = isRefAllele; } slReverse(&variant->alleles); return variant; } -struct variant *variantFromPgSnpAnnoRow(struct annoRow *row, char *refAllele, struct lm *lm) +struct variant *variantFromPgSnpAnnoRow(struct annoRow *row, char *refAllele, boolean hasBin, + struct lm *lm) /* Translate pgSnp annoRow into variant (allocated by lm). */ { struct pgSnp pgSnp; -pgSnpStaticLoad(row->data, &pgSnp); +char **words = row->data; +char *wordsWithFakeBin[PGSNP_NUM_COLS]; +if (! hasBin) + { + // pgSnp file input doesn't have a bin column, but the pgSnp code expects one -- + // so make a fake bin column to ignore. + wordsWithFakeBin[0] = "1"; + int i; + for (i = 1; i < PGSNP_NUM_COLS; i++) + wordsWithFakeBin[i] = words[i-1]; + words = wordsWithFakeBin; + } +pgSnpStaticLoad(words, &pgSnp); return variantNew(pgSnp.chrom, pgSnp.chromStart, pgSnp.chromEnd, pgSnp.alleleCount, pgSnp.name, refAllele, lm); } struct variant *variantFromVcfAnnoRow(struct annoRow *row, char *refAllele, struct lm *lm, struct dyString *dyScratch) /* Translate vcf array of words into variant (allocated by lm, overwriting dyScratch * as temporary scratch string). */ { char **words = row->data; char *alStr = vcfGetSlashSepAllelesFromWords(words, dyScratch); // The reference allele is the first allele in alStr -- and it may be trimmed on both ends with // respect to the raw VCF ref allele in words[3], so copy vcfRefAllele back out of alStr. // That ensures that variantNew will get the reference allele that matches the slash-separated // allele string.