예제 #1
0
def test_import_contigs_valid_input():
   
   expected_output = {"GCA-000007265-protein1_1":"ATGGTACAATATAACAATAATTATCCACAAGACAATAAGGAAGAAGCTATGACGGAAAACGAACAACTATTTTGGAATAGAGTACTAGAGCTATCTCGTTCTCAAATAGCACCAGCAGCTTATGAATTTTTTGTTCTAGAGGCTAGACTCCTCAAAATTGAACATCAAACTGCAGTTATTACTTTAGATAACATTGAAATGAAAAAGCTATTCTGGGAACAAAATTTGGGGCCTGTTATCCTAACAGCTGGTTTTGAAATTTTCAATGCTGAAATTACAGCTAACTATGTCTCAAACGATTTACATTTACAAGAAACTAGTTTTTCTAACTACCAGCAATCTAGCAATGAAGTAAATACTTTACCAATTAGAAAAATCGACTCTAACCTTAAAGAGAAATATACTTTTGCTAATTTTGTTCAAGGAGATGAAAATAGATGGGCTGTTTCAGCATCAATTGCTGTAGCTGATAGTCCTGGCACGACTTATAATCCTCTATTTATCTGGGGGGGACCTGGTCTAGGAAAGACGCATCTACTAAATGCTATTGGAAATCAAGTCTTAAGAGATAATCCAAACGCGAGGGTTTTATACATCACTGCTGAGAATTTTATTAATGAATTTGTCAGTCATATTCGTTTAGATTCGATGGAAGAATTAAAAGAAAAGTTTCGCAACTTAGACTTACTCCTGATTGATGATATTCAGTCGCTTGCTAAGAAAACCTTAGGGGGGACCCAAGAGGAGTTCTTCAATACTTTCAATGCTTTACATACAAACGATAAACAAATCGTATTGACCAGTGACCGAAATCCAAATCAATTAAATGATCTAGAAGAACGTCTAGTCACGCGCTTTAGTTGGGGACTCCCAGTAAATATCACACCACCTGATTTTGAAACACGAGTTGCTATTTTAACCAATAAAATTCAAGAATATCCTTATGATTTTCCTCAAGATACCATTGAATACTTAGCAGGAGAATTTGATTCCAACGTACGTGAATTAGAAGGAGCCTTGAAAAATATTAGTCTAGTTGCTGACTTTAAGCATGCTAAAACTATTACAGTAGATATAGCTGCAGAAGCTATCAGAGCACGTAAAAATGATGGTCCTATTGTTACTGTCATTCCTATAGAAGAAATTCAAATACAAGTTGGTAAATTCTATGGCGTAACTGTAAAAGAGATAAAAGCAACTAAAAGAACACAAGATATTGTCCTTGCAAGACAGGTAGCCATGTACTTAGCTCGTGAGATGACAGATAACAGTCTCCCAAAAATAGGTAAAGAATTTGGGGGACGAGATCACTCAACTGTTCTCCACGCTTATAATAAAATAAAAAATATGGTTGCTCAAGATGACAACTTACGAATTGAGATAGAAACTATCAAAAATAAAATCAGATAG"}
   
   output = rfm.import_contigs("GCA-000007265-protein1.fasta")
   
   assert output == expected_output
예제 #2
0
def test_import_contigs_invalid_file_inputs(file_input, expected):
        """Tests the behaviour of the import_contigs function with unexpected file inputs"""
        assert rfm.import_contigs(file_input) == expected
예제 #3
0
def test_import_contigs_invalid_inputs(test_input, expectation):
        """Tests the behaviour of the import_contigs function with unexpected inputs"""
        with expectation:
                rfm.import_contigs(test_input)    
예제 #4
0
         (pytest.param("invalid.fasta", {'ContigID': 'REALLIYINAVLIDFASTASEQUENCE'}, marks=pytest.mark.xfail)),                                 # Test with an invalid fasta file input. The file has an ID and an invalid DNA/protein sequence.
         (pytest.param("empty.fasta", {'ContigID': ''}, marks=pytest.mark.xfail)),                                                              # Test with an empty fasta file input. The file has an ID but no sequence.
         ("/home/pcerqueira/Lab_Software/testing/tests/GCA-000007265-protein1.fasta", expected_output)                                          # Test with a valid input.
         ])
def test_import_contigs_invalid_file_inputs(file_input, expected):
        """Tests the behaviour of the import_contigs function with unexpected file inputs"""
        assert rfm.import_contigs(file_input) == expected

##############################################################


#### TEST extract_coding_sequences ########################################

orf_file_path = "GCA_000007265.1_ASM726v1_genomic.fna_ORF.txt"

contigs = rfm.import_contigs("GCA_000007265.1_ASM726v1_genomic.fna")

valid_output = rfm.extract_coding_sequences(orf_file_path, contigs, 0, 0)

@pytest.mark.parametrize(
        "reading_frames, contigs, starting_id, genome_id, expectation",
        [([],[],[],[], pytest.raises(TypeError)),                       # Test empty list input
         ("","","","", pytest.raises(FileNotFoundError)),               # Test empty string input
#         (7,7,7,5, pytest.raises(TypeError)),
         (orf_file_path, "", "", "", pytest.raises(TypeError)),         # Test with vaild file and empty string input
         (orf_file_path, contigs, "", "", pytest.raises(TypeError)),    # Test with valid file, contig dict and empty string input
         ])
def test_extract_coding_sequences_invalid_inputs(reading_frames, contigs, starting_id, genome_id, expectation):
        """Tests the behaviour of the extract_coding_sequences function with unexpected inputs"""
        with expectation:
                rfm.extract_coding_sequences(reading_frames, contigs, starting_id, genome_id)   
예제 #5
0
def test_import_contigs_existing_empty_txt_input():
   rfm.import_contigs("existing.txt")
예제 #6
0
def test_import_contigs_unexisting_txt_input():
   with pytest.raises(FileNotFoundError):
       rfm.import_contigs("unexisting.txt")
예제 #7
0
def test_import_contigs_int_input():
   with pytest.raises(TypeError):
       rfm.import_contigs(9)
예제 #8
0
def test_import_contigs_empty_list_input():
   rfm.import_contigs([])
예제 #9
0
def test_import_contigs_no_args():
   with pytest.raises(TypeError):
       rfm.import_contigs()