Beispiel #1
0
def process(filename_a, filename_b):
    a = open(filename_a)
    b = open(filename_b)

    _, sequence_a = utils.load(a)
    a.close()

    _, sequence_b = utils.load(b)
    b.close()
    print(utils.compare(sequence_a, sequence_b))
Beispiel #2
0
def compare(filename_a, filename_b):
    a = open(filename_a)
    b = open(filename_b)

    _, sequence_a = utils.load(a)
    a.close()

    _, sequence_b = utils.load(b)
    b.close()

    return utils.compare(sequence_a, sequence_b)
Beispiel #3
0
def process(in_filename, out_filename):
    in_file = open(in_filename)
    out_file = open(out_filename, 'w')

    header, sequence = utils.load(in_file)
    in_file.close()

    out_file.write(header + '\n')
    out_file.write('\n'.join(utils.prepare_subsequences(utils.translate(sequence), 80)))

    out_file.close()
Beispiel #4
0
def load_test():
    # Given
    f = open('test.tmp')

    # When
    header, sequence = utils.load(f)
    f.close()

    # Then
    assert header == '>header'
    assert sequence == 'AGCTGC'
Beispiel #5
0
def process(model_file, sequence_file, window_size):
    model = json.loads(model_file.read())
    model_file.close()

    header, sequence = utils.load(sequence_file)
    sequence_file.close()

    print(header)
    hmm = HMM(**model['model'])

    subsequences = utils.prepare_subsequences(sequence, window_size)

    decoded = ''
    for seq in subsequences:
        decoded += ''.join(hmm.decode(seq)[1])
        print('{} / {}'.format(len(decoded), 3 * len(sequence)), file=sys.stderr)

    lines = utils.prepare_subsequences(decoded, 80)
    for l in lines:
        print(l)
Beispiel #6
0
def process(sequence_file):
    header, sequence = utils.load(arguments['<fasta_sequence>'])
    gene_sequence = utils.to_codon_sequence(sequence)
    hmm = create_from_sequence(gene_sequence)
    print(json.dumps({'header': header, 'model': hmm.__dict__}, sort_keys=True, indent=4, separators=(',', ': ')))