<commit_before>
import models
from Bio.Seq import Seq
import math
import tags

trans_table = 1 # standard translation table
min_protein_len = 200

def detect_orfs(sequence_object):
    sequence_object.clear_orf_features()

    # double up sequence, so we can detect features across 0 bp
    # boundary
    seq = Seq(sequence_object.sequence*2)
    seq_len = len(sequence_object.sequence)
    aa_len = int(math.floor(seq_len/3.0))

    for strand,nuc in [(+1,seq), (-1,seq.reverse_complement())]:
        for frame in range(3):
            #print 'strand '+str(strand)+' frame '+str(frame)

            trans = str(nuc[frame:].translate(trans_table))
            trans_len = len(trans)
            aa_start = 0
            aa_end = 0

            # go through the translation and find end codons that
            # follow a start codon.
            while aa_start < trans_len and aa_start < aa_len:
                # Since we doubled up the sequence to find ORFs across
                # boundaries, we want to make sure we limit possible
                # ORF to be less than aa_len -- hence the +aa_len
                # here.
                aa_end = trans.find("*", aa_start, aa_start+aa_len)
                has_stop = 1
                if aa_end == -1:
                    # no more stop codon, just abort...
                    break

                start_codon = trans.find('M', aa_start, aa_end)

                # is there a start codon? and is it before end of
                # sequence
                if start_codon == -1 or start_codon >= aa_len:
                    assert(aa_end != -1)
                    aa_start = aa_end+1
                    continue

                #print str(aa_len)+": "+str(start_codon)+"-"+str(aa_end)

                if aa_end-start_codon >= min_protein_len:
                    #print 'found '+trans[start_codon:aa_end]

                    # the following start and end need to start with
                    # 1, not 0.
                    if strand == 1:
                        start = frame+start_codon*3+1
                        end = frame+aa_end*3+has_stop*3
                        if end > seq_len:
                            end = end % seq_len
                    else:
                        start = seq_len-frame-aa_end*3-has_stop*3+1
                        end = seq_len-frame-start_codon*3<commit_msg>smaller ORF<commit_after>
import models
from Bio.Seq import Seq
import math
import tags

trans_table = 1 # standard translation table
min_protein_len = 150

def detect_orfs(sequence_object):
    sequence_object.clear_orf_features()

    # double up sequence, so we can detect features across 0 bp
    # boundary
    seq = Seq(sequence_object.sequence*2)
    seq_len = len(sequence_object.sequence)
    aa_len = int(math.floor(seq_len/3.0))

    for strand,nuc in [(+1,seq), (-1,seq.reverse_complement())]:
        for frame in range(3):
            #print 'strand '+str(strand)+' frame '+str(frame)

            trans = str(nuc[frame:].translate(trans_table))
            trans_len = len(trans)
            aa_start = 0
            aa_end = 0

            # go through the translation and find end codons that
            # follow a start codon.
            while aa_start < trans_len and aa_start < aa_len:
                # Since we doubled up the sequence to find ORFs across
                # boundaries, we want to make sure we limit possible
                # ORF to be less than aa_len -- hence the +aa_len
                # here.
                aa_end = trans.find("*", aa_start, aa_start+aa_len)
                has_stop = 1
                if aa_end == -1:
                    # no more stop codon, just abort...
                    break

                start_codon = trans.find('M', aa_start, aa_end)

                # is there a start codon? and is it before end of
                # sequence
                if start_codon == -1 or start_codon >= aa_len:
                    assert(aa_end != -1)
                    aa_start = aa_end+1
                    continue

                if aa_end-start_codon >= min_protein_len:
                    #print 'found '+trans[start_codon:aa_end]

                    # the following start and end need to start with
                    # 1, not 0.
                    if strand == 1:
                        start = frame+start_codon*3+1
                        end = frame+aa_end*3+has_stop*3
                        if end > seq_len:
                            end = end % seq_len
                    else:
                        start = seq_len-frame-aa_end*3-has_stop*3+1
                        end = seq_len-frame-start_codon*3
{'fraction_non_alphanumeric': 0.08090128755364807, 'fraction_numerical': 0.012446351931330472, 'mean_word_length': 1.446719160104987, 'pattern_counts': {'":': 1, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6864842', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1261, 'n_words': 379}