Skip to content

Commit

Permalink
v2.0.30 case-insensitive guides, fix #17
Browse files Browse the repository at this point in the history
  • Loading branch information
kclem committed Jul 2, 2019
1 parent 702b9dc commit 60f9005
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
9 changes: 5 additions & 4 deletions CRISPResso2/CRISPRessoCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,8 @@ def print_stacktrace_if_debug():
this_contains_guide = True

for guide_idx, guide_seq in enumerate(guides):
if guide_seq in this_sgRNA_sequences:
#this_sgRNA_sequences contains all good guides contained in this amplicon
if guide_seq.upper() in this_sgRNA_sequences:
found_guide_seq[guide_idx] = True

# Calculate coding sequence for this reference
Expand Down Expand Up @@ -1803,11 +1804,11 @@ def calculate_range(l):
unmod_pct = "NA"
mod_pct = "NA"
if n_aligned > 0:
unmod_pct = 100*n_unmod/float(n_aligned)
mod_pct = 100*n_mod/float(n_aligned)
unmod_pct = round(100*n_unmod/float(n_aligned),8)
mod_pct = round(100*n_mod/float(n_aligned),8)

vals = [ref_name]
vals.extend([str(x) for x in [round(unmod_pct,8),round(mod_pct,8),n_aligned,N_TOTAL,n_unmod,n_mod,n_discarded,n_insertion,n_deletion,n_substitution,n_only_insertion,n_only_deletion,n_only_substitution,n_insertion_and_deletion,n_insertion_and_substitution,n_deletion_and_substitution,n_insertion_and_deletion_and_substitution]])
vals.extend([str(x) for x in [unmod_pct,mod_pct,n_aligned,N_TOTAL,n_unmod,n_mod,n_discarded,n_insertion,n_deletion,n_substitution,n_only_insertion,n_only_deletion,n_only_substitution,n_insertion_and_deletion,n_insertion_and_substitution,n_deletion_and_substitution,n_insertion_and_deletion_and_substitution]])
outfile.write("\t".join(vals) + "\n")

crispresso2_info['quant_of_editing_freq_filename'] = os.path.basename(quant_of_editing_freq_filename)
Expand Down
8 changes: 5 additions & 3 deletions CRISPResso2/CRISPRessoPooledCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def main():
info('Checking dependencies...')

if check_samtools() and check_bowtie2():
info('\n All the required dependencies are present!')
info('All the required dependencies are present!')
else:
sys.exit(1)

Expand Down Expand Up @@ -463,10 +463,12 @@ def main():
df_template.Coding_sequence=df_template.Coding_sequence.apply(capitalize_sequence)

if not len(df_template.Amplicon_Sequence.unique())==df_template.shape[0]:
raise Exception('The amplicons should be all distinct!')
duplicated_entries = df_template.Amplicon_Sequence[df_template.Amplicon_Sequence.duplicated()]
raise Exception('The amplicon sequences must be distinct! (Duplicated entries: ' + str(duplicated_entries.values) + ')')

if not len(df_template.Name.unique())==df_template.shape[0]:
raise Exception('The amplicon names should be all distinct!')
duplicated_entries = df_template.Name[df_template.Name.duplicated()]
raise Exception('The amplicon names must be distinct! (Duplicated names: ' + str(duplicated_entries.values) + ')')

df_template=df_template.set_index('Name')
df_template.index=df_template.index.to_series().str.replace(' ','_')
Expand Down
12 changes: 6 additions & 6 deletions CRISPResso2/CRISPRessoShared.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
else:
import cPickle as cp #python 2.7

__version__ = "2.0.29"
__version__ = "2.0.30"

###EXCEPTIONS############################
class FlashException(Exception):
Expand Down Expand Up @@ -638,14 +638,14 @@ def get_amplicon_info_for_guides(ref_seq,guides,quantification_window_center,qua
for guide_idx, current_guide_seq in enumerate(guides):
offset_fw=quantification_window_center+len(current_guide_seq)-1
offset_rc=(-quantification_window_center)-1
new_cut_points=[m.start() + offset_fw for m in re.finditer(current_guide_seq, ref_seq)]+\
[m.start() + offset_rc for m in re.finditer(reverse_complement(current_guide_seq), ref_seq)]
new_cut_points=[m.start() + offset_fw for m in re.finditer(current_guide_seq, ref_seq, flags=re.IGNORECASE)]+\
[m.start() + offset_rc for m in re.finditer(reverse_complement(current_guide_seq), ref_seq, flags=re.IGNORECASE)]

if (new_cut_points):
this_sgRNA_cut_points += new_cut_points
this_sgRNA_intervals+=[(m.start(),m.start()+len(current_guide_seq)-1) for m in re.finditer(current_guide_seq, ref_seq)]+\
[(m.start(),m.start()+len(current_guide_seq)-1) for m in re.finditer(reverse_complement(current_guide_seq), ref_seq)]
this_sgRNA_sequences.append(current_guide_seq)
this_sgRNA_intervals+=[(m.start(),m.start()+len(current_guide_seq)-1) for m in re.finditer(current_guide_seq, ref_seq, flags=re.IGNORECASE)]+\
[(m.start(),m.start()+len(current_guide_seq)-1) for m in re.finditer(reverse_complement(current_guide_seq), ref_seq, flags=re.IGNORECASE)]
this_sgRNA_sequences.append(current_guide_seq.upper())

#create mask of positions in which to include/exclude indels for the quantification window
#first, if exact coordinates have been given, set those
Expand Down

0 comments on commit 60f9005

Please sign in to comment.