Пример #1
0
def main():
    '''
    define input and output files and, write final output to a file handle
    :return:
    '''
    argvs = get_cli_args()
    in_file = argvs.INFILE
    out_file = argvs.OUTFILE
    fh_in = get_fh(in_file, "r")
    list_headers, list_sequences = get_header_and_sequence_lists(fh_in)
    fh_out = get_fh(out_file, "w")
    print_sequence_stats(list_headers, list_sequences, fh_out)
    fh_out.close()
def test_get_fh():
    fh_in = open("test.txt", "r")
    assert get_fh("test.txt", "r") == fh_in
    fh_out = open("out.txt", "w")
    assert get_fh("out.txt", "w") == fh_out
Пример #3
0
def test_get_fh_4_IOError():
    # does it raise IOError
    # this should exit
    with pytest.raises(SystemExit):
        get_fh("does_not_exist.txt", "r")
Пример #4
0
def test_get_fh_4_ValueError():
    # does it raise IOError
    # this should exit
    with pytest.raises(SystemExit):
        get_fh("ss.txt", "rrr")
Пример #5
0
"""
Test Suite for PDB_FASTA_SPLITTER
"""
import pytest

# pylint: disable=C0116
# pylint: disable=C0103

from pdb_fasta_splitter import write_in_file, _check_size_of_lists, \
    get_header_and_sequence_lists, get_fh

LIST_HEADER = ['>1sequence', '>1secstr', ">2sequence", ">2secstr"]
LIST_SEQS = ['ACGTAC', 'ACGTCC', 'ACCGGT', 'AAAACT']
LIST_SEQS_NOT_EQUAL = ['ACGTAC', 'ACGTCC', 'ACCGGT']
FILE_HANDLE = get_fh("ss.txt", "r")
AMINO_ACID = get_fh("test_pdb_protein.fasta", "w")
SEC_STR = get_fh("test_pdb_ss.fasta", "w")


def test_write_in_file():
    count_amino, count_sec_str = write_in_file(AMINO_ACID, SEC_STR, LIST_HEADER, LIST_SEQS)
    assert count_amino == 2
    assert count_sec_str == 2


def test__check_size_of_lists():
    assert _check_size_of_lists(LIST_HEADER, LIST_SEQS)
    with pytest.raises(SystemExit):
        _check_size_of_lists(LIST_HEADER, LIST_SEQS_NOT_EQUAL)