def cached_assay_cut_by_enzyme(assay, enzyme): """ Check the cached information to see whether the enzyme cuts the amplicon. If the sequence and SNP information is not cached, return False. Otherwise, return whether or not the enzyme cuts the assay's amplicon. More conditions: * The cut site must be wholly contained within the amplicon (no overhang) * All the sequences that match the assay must have a cut site within the amplicon. :param assay: An Assay DB object. :param enzyme: An Enzyme DB object. :return: False if the assay's sequence is not cached; otherwise, whether the enzyme is theoretically guaranteed to cut all sequences corresponding to the assay. """ if not assay.cached_sequences: return False cuts_all = False max_cuts = 10000000 for seq in assay.cached_sequences: amplicon = SimpleGenomeSequence(seq.chromosome, seq.start_pos, seq.end_pos, "+", seq.positive_amplicon) try: snps = [snp for snp in seq.snps if snp.chromEnd >= seq.start_pos and snp.chromStart <= seq.end_pos] mutated_sequences = mutate_sequences(CachedSNP131Transformer(), amplicon, snps, len(enzyme.cutseq)) except ReturnWithCaveats, e: mutated_sequences = e.return_value # could not read for some other reason except Exception, e: return 0
def test_find_in_sequences(): source = HG19Source() xf = SNP131Transformer() sequence = SimpleGenomeSequence(9, 2364849, 2364871, '+', 'TAAGCAAATAACTTTATATAAAC') sequence_inv = SimpleGenomeSequence(9, 2364849, 2364871, '-', 'GTTTATATAAAGTTATTTGCTTA') snps = source.snps_in_range(sequence.chromosome, sequence.start, sequence.end) try: variants = mutate_sequences(xf, sequence, snps, 6) except ReturnWithCaveats, e: variants = e.return_value
def __enzyme_cut_locations(self, pcr_seq, enzymes): if not enzymes: return dict() edict = dict([(e.name, e.cutseq) for e in enzymes]) combined_sequence = pcr_seq.merged_positive_sequence amplicon_location_start = pcr_seq.amplicon.start amplicon_location_end = pcr_seq.amplicon.end enzyme_length = max([len(enzyme.cutseq) for enzyme in enzymes]) try: mutated_sequences = mutate_sequences(SNP131Transformer(), combined_sequence, pcr_seq.snps, enzyme_length, combined_sequence.strand) except ReturnWithCaveats, e: # TODO show error message mutated_sequences = e.return_value