###grab slice of sequence fom this window. targetRec = rec[slice_start:slice_end] matching_feature = [f for f in targetRec.features if f.id == mytarget.id] if matching_feature: target_feat = matching_feature[0] my_target_dict={} # re-initialize target dictionary if target_feat.location.start.position == 0: target_feat.location.start.position = 1 #get the mask features by removing target...all features are masked as just using snp and indels, a smarter filter could be added exclude_feat = list(targetRec.features) ##list copy to avoid possible side-effects exclude_feat.remove(target_feat) my_target_dict={'SEQUENCE_ID' : rec.name,\ 'SEQUENCE_TEMPLATE': targetRec.seq.tostring().upper(),\ 'SEQUENCE_TARGET': [target_feat.location.start.position,1],\ 'SEQUENCE_EXCLUDED_REGION': [[x.location.start.position,x.location.end.position -x.location.start.position] for x in exclude_feat]} result=P3.run_P3(target_dict=my_target_dict,global_dict=def_dict) if my_args.run_uMelt: amp_seq=targetRec.seq ##need to make this conditional on getting a result >0 and melt=True mutamp_seq=targetRec.seq.tomutable() mutamp_seq[target_feat.location.start:target_feat.location.end]=target_feat.qualifiers['Variant_seq'][0] #mutate to variant other_SNP=[f for f in targetRec.features if f.id != mytarget.id] if other_SNP: for snp in other_SNP: mutamp_seq[snp.location.start:snp.location.end]=snp.qualifiers['Variant_seq'][0] for primerset in result: amp_start=int(primerset['PRIMER_LEFT'][0]) amp_end=int(primerset['PRIMER_RIGHT'][0]) ref_melt_Tm=0 var_melt_Tm=0 diff_melt=0 if my_args.run_uMelt:
str(x.location.end.position - x.location.start.position) for x in exclude_feat ]) my_target_dict = { 'SEQUENCE_ID': rec.name, 'SEQUENCE_TEMPLATE': targetRec.seq.tostring(), 'SEQUENCE_TARGET': str(target_feat.location.start.position) + ',1', 'SEQUENCE_INTERNAL_EXCLUDED_REGION': excludes_str } my_target_dict.update(def_dict) ##add in defaults result = P3.run_P3(target_dict=my_target_dict) if my_args.run_uMelt: amp_seq = targetRec.seq ##need to make this conditional on getting a result >0 and melt=True mutamp_seq = targetRec.seq.tomutable() mutamp_seq[target_feat.location.start:target_feat. location.end] = target_feat.qualifiers[ 'Variant_seq'][ 0] #mutate to variant for primerset in result: amp_start = int( primerset['PRIMER_LEFT'].split(',')[0]) amp_end = int( primerset['PRIMER_RIGHT'].split(',')[0]) ref_melt_Tm = 0 var_melt_Tm = 0 diff_melt = 0
] if matching_feature: target_feat = matching_feature[0] my_target_dict = {} # re-initialize target dictionary if target_feat.location.start.position == 0: target_feat.location.start.position = 1 #get the mask features by removing target...all features are masked as just using snp and indels, a smarter filter could be added exclude_feat = list( targetRec.features ) ##list copy to avoid possible side-effects exclude_feat.remove(target_feat) my_target_dict={'SEQUENCE_ID' : rec.name,\ 'SEQUENCE_TEMPLATE': targetRec.seq.tostring().upper(),\ 'SEQUENCE_TARGET': [target_feat.location.start.position,1],\ 'SEQUENCE_EXCLUDED_REGION': [[x.location.start.position,x.location.end.position -x.location.start.position] for x in exclude_feat]} result = P3.run_P3(target_dict=my_target_dict, global_dict=def_dict) if my_args.run_uMelt: amp_seq = targetRec.seq ##need to make this conditional on getting a result >0 and melt=True mutamp_seq = targetRec.seq.tomutable() mutamp_seq[target_feat.location.start:target_feat. location.end] = target_feat.qualifiers[ 'Variant_seq'][ 0] #mutate to variant other_SNP = [ f for f in targetRec.features if f.id != mytarget.id ] if other_SNP: for snp in other_SNP: mutamp_seq[snp.location.start:snp.location. end] = snp.qualifiers[
slice_end = featLocation + my_args.prod_max_size ###grab slice of sequence fom this window. targetRec = rec[slice_start:slice_end] matching_feature = [f for f in targetRec.features if f.id == mytarget.id] if matching_feature: target_feat = matching_feature[0] my_target_dict={} # re-initialize target dictionary if target_feat.location.start.position == 0: target_feat.location.start.position = 1 #get the mask features by removing target...all features are masked as just using snp and indels, a smarter filter could be added exclude_feat = list(targetRec.features) ##list copy to avoid possible side-effects exclude_feat.remove(target_feat) excludes_str=' '.join([str(x.location.start.position)+','+str(x.location.end.position -x.location.start.position) for x in exclude_feat]) my_target_dict={'SEQUENCE_ID' : rec.name, 'SEQUENCE_TEMPLATE': targetRec.seq.tostring(),'SEQUENCE_TARGET': str(target_feat.location.start.position) + ',1','SEQUENCE_INTERNAL_EXCLUDED_REGION': excludes_str} my_target_dict.update(def_dict) ##add in defaults result=P3.run_P3(target_dict=my_target_dict) if my_args.run_uMelt: amp_seq=targetRec.seq ##need to make this conditional on getting a result >0 and melt=True mutamp_seq=targetRec.seq.tomutable() mutamp_seq[target_feat.location.start:target_feat.location.end]=target_feat.qualifiers['Variant_seq'][0] #mutate to variant for primerset in result: amp_start=int(primerset['PRIMER_LEFT'].split(',')[0]) amp_end=int(primerset['PRIMER_RIGHT'].split(',')[0]) ref_melt_Tm=0 var_melt_Tm=0 diff_melt=0 if my_args.run_uMelt: try: ref_melt_Tm=umelts.getTm(umelts.getmelt(amp_seq.tostring()[amp_start:amp_end+1])) var_melt_Tm=umelts.getTm(umelts.getmelt(mutamp_seq.tostring()[amp_start:amp_end+1])) diff_melt=abs(ref_melt_Tm - var_melt_Tm)