I'd like to find all of the PL indices in a VCF line for a specific allele at sites with an arbitrary number of alleles and arbitrary sample ploidy. For dipolid samples, the algorithm is straightforward, but things get more complicated for plodies 3 and above. The related question of finding the PL index given a genotype already has a nice algorithm http://gatkforums.broadinstitute.org/gatk/discussion/2157/gatk-vcf-pl-field-ordering-for-pooled-polyploid-samples.
I already have some code to do this (see below), but it's not very elegant. Does anyone have a better algorithm?