cDNA_Cupcake
cDNA_Cupcake copied to clipboard
List index out of range error in phasing/utils/collect_all_vcf.py
Summarized results of by_loci/
Traceback (most recent call last):
File "./software/cDNA_Cupcake-master/phasing/utils/collect_all_vcf.py", line 14, in <module>
for r in reader: snps_by_chrom[r.CHROM].append((r.POS, r))
File "./software/anaconda2/lib/python2.7/site-packages/vcf/parser.py", line 586, in next
samples = self._parse_samples(row[9:], fmt, record)
File "./software/anaconda2/lib/python2.7/site-packages/vcf/parser.py", line 451, in _parse_samples
self.samples, samples, samp_fmt, samp_fmt._types, samp_fmt._nums, site)
File "vcf/cparse.pyx", line 25, in vcf.cparse.parse_samples
IndexError: list index out of range
Dear Liz, When running cDNA_cupcake, I'm encountering the following error. With the ** marked line removed ,it'll worked fine; but the result will lost the informations of the samples .
Please help us. Thanks ....
import os
import vcf
import glob
from collections import defaultdict
dirs = glob.glob('by_loci/*size*')
snps_by_chrom = defaultdict(lambda: [])
for d in dirs:
filename = os.path.join(d, 'phased.partial.vcf')
if not os.path.exists(filename): continue
reader = vcf.VCFReader(open(filename))
**reader.samples = []**
for r in reader: snps_by_chrom[r.CHROM].append((r.POS, r))
keys = snps_by_chrom.keys()
keys.sort()
f = vcf.Writer(open('IsoSeq_IsoPhase.vcf', 'w'), reader)
for k in keys:
v = snps_by_chrom[k]
v.sort(key=lambda x: x[0])
for pos,rec in v:
rec.samples = []
f.write_record(rec)
f.close()