Esempio n. 1
0
def readinput( path ):
    """
    Read all the segments from FASTA file. Return Fasta object.
    """
    fasta = Fasta( path )
    for i in range( len(fasta.get_segments()) ):
        seg = fasta.get_segments()[i]
        seq = seg.get_sequence()
        print( seg.get_header() + "\n" + seq )
    return fasta
Esempio n. 2
0
def execute():
    fasta = Fasta( "rosalind_tran.txt" )
    s1 = fasta.get_segments()[0].get_sequence().upper()
    s2 = fasta.get_segments()[1].get_sequence().upper()
    print( "s1",s1 )
    print( "s2",s2)
    ratio = compute_ratio( s1, s2 )
    print( "ratio=" + str(ratio) )
Esempio n. 3
0
def readinput( path ):
    """
    Read input from FASTA file.
    """
    fasta = Fasta( path )
    segs = fasta.get_segments()
    s = segs[0].get_sequence()
    t = segs[1].get_sequence()
    return s,t
Esempio n. 4
0
def execute():
    fasta = Fasta( "rosalind_revp.txt" )
    output = open( "output_revp.txt", "w" )
    dna = fasta.get_segments()[0].get_sequence()
    #print( dna )
    restrictions = find_restrictions( dna )
    for i in range(len(restrictions)):
        print( str(restrictions[i][0])+" "+str(restrictions[i][1]))
        output.write(str(restrictions[i][0])+" "+str(restrictions[i][1]))
        output.write("\n")
Esempio n. 5
0
def execute():
    """
    text_file = open( "rosalind_hamm.txt", "r")
    s = text_file.readline().rstrip()
    t = text_file.readline().rstrip()
    text_file.close()
    """

    from fasta import Fasta

    fasta = Fasta( "rosalind_tran.txt" )
    s = fasta.get_segments()[0].get_sequence().upper()
    t = fasta.get_segments()[1].get_sequence().upper()
    if len(s) != len(t):
        raise Exception( "lengths do not match" )
    
    print( hamm_dist(s,t) )
Esempio n. 6
0
def readinput(path):
    fasta = Fasta(path)
    seq = fasta.get_segments()[0].get_sequence()
    return seq