def ref_sequence_abundances(): from samsum import commands from samsum import testing_utils as utils test_sam = utils.get_test_data("samsum_test_2.sam") test_aln = utils.get_test_data("samsum_test_2.fasta") ref_seq_abunds = commands.ref_sequence_abundances(aln_file=test_sam, seq_file=test_aln, min_aln=10, p_cov=0, map_qual=0) return ref_seq_abunds
def test_ref_sequence_abundances(): from samsum import commands from samsum.classy import RefSequence test_sam = utils.get_test_data("samsum_test_2.sam") test_aln = utils.get_test_data("samsum_test_2.fasta") ref_seq_abunds = commands.ref_sequence_abundances(aln_file=test_sam, seq_file=test_aln, min_aln=10, p_cov=0, map_qual=0) e10 = ref_seq_abunds[ 'AB-755_P22_E10_NODE_6_length_36342_cov_2156.57_ID_21'] # type: RefSequence assert e10.reads_mapped == 10 assert e10.weight_total == 5.0 return
def test_get_mapped_reads(): from samsum import _sam_module test_sam = utils.get_test_data('pytest_1.sam') assert isinstance(test_sam, str) mapping_list = _sam_module.get_mapped_reads(test_sam, False, 10, 0, 'q') assert (len(mapping_list) == 16) return
def test_ref_sequence_length(): """ Ensure the RefSequence.rightmost doesn't exceed its length from alignment_dat_example.load_sam() :return: """ from samsum import file_parsers as ss_fp from samsum import alignment_utils as ss_aln_utils test_seq = utils.get_test_data("samsum_test_2.fasta") test_aln = utils.get_test_data("samsum_test_2.sam") ref_seq_lengths = ss_fp.fasta_seq_lengths_ext(fasta_file=test_seq) assert len(ref_seq_lengths) == 277 # Parse the alignments and return the strings of reads mapped to each reference sequence mapped_dict = ss_fp.sam_parser_ext(test_aln, True) # Convert the alignment strings returned by the sam_parser_ext into ss_class.AlignmentDat instances alignments, num_unmapped, mapped_weight_sum = ss_aln_utils.load_alignments( mapped_dict, 10) for aln_dat in alignments: # type: samsum.classy.AlignmentDat assert aln_dat.end < ref_seq_lengths[aln_dat.ref] return
def test_fasta_reader(): from samsum import file_parsers as ss_fp test_seq = utils.get_test_data("fasta_test.fa") ref_seq_lengths = ss_fp.fasta_seq_lengths_ext(fasta_file=test_seq) assert ref_seq_lengths == {"contig 1": 16, "contig 2": 25} return
def sam_list(): data_path = utils.get_test_data("test-data") filenames = sorted(glob.glob(os.path.join(data_path, "*.sam"))) return filenames