コード例 #1
0
def findAllOrf(text, limit):  # look for the file, and call the other functions


    if ((len(sys.argv) < 2) or (len(sys.argv) > 3)):
        print "Usage: python", sys.argv[0], "<filename> [<min ORF length>]"
    else:
        fileName = sys.argv[1]
        if (len(sys.argv) > 2):             # This should be an integer
            try:
                limit = int(sys.argv[2])    # Convert string to integer
            except ValueError:              # try-except catches errors
                print "\n\tExpecting an integer to define min ORF length, found",
                print sys.argv[2]
                exit()

    
    print "ORF must be at least", limit, "Base pairs long"
    
    text = cs58FileUtil.readFastaFile(fileName)
    
    process_all_reading_frames(text,limit)
コード例 #2
0
    longest_pal = "Longest Palindrome @ Position: ", pos, "Sequence:", longest_pal
    return longest_pal


#This a recursive method I previously developed for checking
# palindromes of a single small string. I thought
# to use it to submit substrings to here and return true
# if indeed the substring is a palindrome
def isPalindrome(sub_seq, sub_comp):
    sub_seq_length = len(sub_seq)
    sub_comp_length = len(sub_comp)
    # base case for recursion
    if sub_seq_length <= 1 or sub_comp_length <= 1:
        return True
    #if first char equals last char, call method again
    if sub_seq[0] == sub_comp[0]:
        return isPalindrome(sub_seq[1:], sub_comp[1:])

    # if this statement is reached, it cannot be a palindrome
    return False


if (len(sys.argv) != 2):
    print "Usage: python", sys.argv[0], "<filename>"
else:
    fileName = sys.argv[1]
    seq = cs58FileUtil.readFastaFile(fileName)
    comp_seq = comp_strand(seq)
    print find_palindromes(seq, comp_seq)
コード例 #3
0
ファイル: findPalindrome.py プロジェクト: ashbig/bioinfo
                    
    longest_pal = "Longest Palindrome @ Position: ", pos, "Sequence:", longest_pal               
    return longest_pal


#This a recursive method I previously developed for checking
# palindromes of a single small string. I thought
# to use it to submit substrings to here and return true
# if indeed the substring is a palindrome
def isPalindrome (sub_seq, sub_comp ):
    sub_seq_length= len(sub_seq)
    sub_comp_length= len(sub_comp)
    # base case for recursion
    if sub_seq_length<=1 or sub_comp_length <=1 :
        return True
    #if first char equals last char, call method again
    if sub_seq[0] == sub_comp[0]:
        return isPalindrome(sub_seq[1:], sub_comp[1:])
        
    # if this statement is reached, it cannot be a palindrome
    return False
        
if (len(sys.argv) !=2):
    print "Usage: python", sys.argv[0], "<filename>"
else:
    fileName =sys.argv[1]
    seq = cs58FileUtil.readFastaFile(fileName)
    comp_seq =comp_strand(seq)
    print find_palindromes(seq, comp_seq)
    
コード例 #4
0
            this_snippet = seq[cursor:cursor+length_to_try]
            reverse = reverseComplement(this_snippet)
            if this_snippet == reverse:  #if we get a palindrome, save it and move on to checking the next length
                this_start = cursor + 1
                best_so_far = [this_snippet, this_start]
                length_to_try +=2
                cursor = 0
            else:         #if not a palindrome, keep checking snippets of this length
                cursor += 1    
        found_longest=True  #If we make it here, no palindromes for that length so we're done

    return best_so_far 

                
if ((len(sys.argv) < 2) or (len(sys.argv) > 3)):
    print "Usage: python", sys.argv[0], "<filename>"
else:
    fileName = sys.argv[1]
    if (len(sys.argv) > 2):             # This should be an integer
        try:
            limit = int(sys.argv[2])    # Convert string to integer
        except ValueError:              # try-except catches errors
            print sys.argv[2]
            exit()       
            
    
    text = readFastaFile(fileName) #remove 'cs58FileUtil" because it was giving a not defined error
    text = prepare(text)
    print find_longest_palindrome (text)
    
profile.run("find_longest_palindrome(text)")
コード例 #5
0
ファイル: repeat.py プロジェクト: dianekaplan/rosalind
        if this_result[winner] > 1:
            biggest_repeat_length =  attempting_length 
            biggest_repeat = winner
            best_result = this_result
        else: 
            not_stumped = False
        attempting_length +=1 
        
    if (DEBUG):
        return biggest_repeat_length, biggest_repeat, best_result 
                
    return biggest_repeat_length, biggest_repeat



if ((len(sys.argv) < 2) or (len(sys.argv) > 3)):
    print "Usage: python", sys.argv[0], "<filename>"
else:
    fileName = sys.argv[1]
    if (len(sys.argv) > 2):             # This should be an integer
        try:
            limit = int(sys.argv[2])    # Convert string to integer
        except ValueError:              # try-except catches errors
            print "\n\tExpecting an integer to define min ORF length, found",
            print sys.argv[2]
            exit()
    
    
    seq = readFastaFile(fileName) 
    seq = prepare(seq)
    print "The biggest repeat in this sequence is: ",find_biggest_repeat(seq)
コード例 #6
0
            this_snippet = seq[cursor:cursor + length_to_try]
            reverse = reverseComplement(this_snippet)
            if this_snippet == reverse:  #if we get a palindrome, try the next length
                this_start = cursor + 1
                best_so_far = [this_snippet, this_start]
                length_to_try += 2
                cursor = 0
            else:  #if not, continue to the end of the sequence to see if there is one
                cursor += 1
        found_longest = True  #If we make it down this far, we've reached the end of the sequence for a length that doesn't have any hits

    return best_so_far


if ((len(sys.argv) < 2) or (len(sys.argv) > 3)):
    print "Usage: python", sys.argv[0], "<filename>"
else:
    fileName = sys.argv[1]
    if (len(sys.argv) > 2):  # This should be an integer
        try:
            limit = int(sys.argv[2])  # Convert string to integer
        except ValueError:  # try-except catches errors
            print "\n\tExpecting an integer to define min ORF length, found",
            print sys.argv[2]
            exit()

    text = readFastaFile(
        fileName
    )  #remove 'cs58FileUtil" because it was giving a not defined error
    print find_longest_palindrome(text)