index error, while executing python -


i beginner in python, executing piece of code throws following error.i tried best solve could't it. please me. code follows.

    continue     num_snps_skipped += 1     samp_id = sline[id_index]     ref_allele = sline[ref_allele_index]     tum_allele = sline[tum_allele_index]     snp = ref_allele + tum_allele     if not snp in transitions:         snp = nucleotide_complement[ref_allele] + nucleotide_complement[tum_allele]     ref_trinuc = sline[ref_tri_index]     if ref_trinuc == "na":         print "warning: reference allele not available on "+\                 "line %d; skipping line"%line_number         continue     if not ref_trinuc[1] == snp[0]:         print "warning: reference allele not match reference "+\                 "trinucleotide; skipping line %d"%line_number**         continue     snp_with_ctx = ref_trinuc[0] + snp + ref_trinuc[2]     if not samp_id in signatures:         signatures[samp_id] = [0 in substitution_order]     if snp_with_ctx not in substitution_order:         print "warning: substitution on line " + \                 "%d %s, not "%(line_number,snp_with_ctx) + \                 "found among possible substitutions. skipping line." 

i getting error follows

    traceback (most recent call last):   file "main.py", line 59, in <module>     signatures = signature.make(args.in_file, substitution_order=stratton['substitution_order'], out_path = args.spectrum_output)   file "/home/ateeqanees/mutation/centos/mutation-signatures-master/signature.py", line 73, in make     if not ref_trinuc[1] == snp[0]: indexerror: string index out of range 

please me. of great help.

thanks lot !!! dav

more ref_trinuc string has 1 or 0 characters. that's why if not ref_trinuc[1] == snp[0]: giving index error, because it's trying grab second character.

before line try printing ref_trinuc see holds.

if normal ref_trinuc shorter 2 characters, try if statement:

if (len(ref_trinuc) > 1) , (not ref_trinuc[1] == snp[0]):

because if length 1 or 0, in case second half not attempted , no index error thrown.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -