sctools.test package
Submodules
sctools.test.test_bam module
- sctools.test.test_bam.indices(request)[source]
fixture returns indices from a SubsetAlignments objects for testing
- sctools.test.test_bam.sa_object(request)[source]
fixture returns SubsetAlignments objects for testing
- sctools.test.test_bam.test_chromosome_19_comes_before_21(indices)[source]
chromosome 19 comes before 21 in the test file, this should be replicated in the output
- sctools.test.test_bam.test_correct_number_of_indices_are_extracted(sa_object, n_specific, n_nonspecific)[source]
- sctools.test.test_bam.test_get_barcode_for_alignment_raises_error_for_missing_tag(tagged_bam)[source]
- sctools.test.test_bam.test_get_barcodes_from_bam_with_raise_missing_true_raises_warning_without_cr_barcode_passed(tagged_bam)[source]
- sctools.test.test_bam.test_incorrect_extension_does_not_raise_when_open_mode_is_specified()[source]
- sctools.test.test_bam.test_indices_are_all_greater_than_zero(sa_object, n_specific, n_nonspecific)[source]
- sctools.test.test_bam.test_sort_by_tags_and_queryname_sorts_correctly_from_file_no_tag_keys()[source]
- sctools.test.test_bam.test_split_bam_raises_value_error_when_passed_bam_without_barcodes(bamfile)[source]
- sctools.test.test_bam.test_split_succeeds_with_raise_missing_false_and_no_cr_barcode_passed(tagged_bam)[source]
- sctools.test.test_bam.test_split_with_raise_missing_true_raises_warning_without_cr_barcode_passed(tagged_bam)[source]
sctools.test.test_barcode module
- sctools.test.test_barcode.test_base_frequency_sums_are_all_equal_to_barcode_set_length(barcode_set)[source]
- sctools.test.test_barcode.test_correct_bam_produces_cb_tags(tagged_bamfile, truncated_whitelist_from_10x)[source]
- sctools.test.test_barcode.test_correct_barcode_finds_and_corrects_1_base_errors(trivial_whitelist)[source]
- sctools.test.test_barcode.test_correct_barcode_raises_keyerror_when_barcode_has_more_than_one_error(trivial_whitelist)[source]
- sctools.test.test_barcode.test_correct_barcode_raises_keyerror_when_barcode_not_correct_length(trivial_whitelist)[source]
- sctools.test.test_barcode.test_iterable_produces_correct_barcodes(short_barcode_set_from_encoded)[source]
sctools.test.test_encodings module
- sctools.test.test_encodings.simple_barcodes()[source]
simple barcode set with min_hamming = 1, max_hamming = 2
- sctools.test.test_encodings.test_encoded_hamming_distance_is_accurate(simple_hamming_distances, simple_barcodes, encoder)[source]
- sctools.test.test_encodings.test_three_bit_encode_decode_produces_same_string(sequence, encoder_3bit)[source]
- sctools.test.test_encodings.test_three_bit_encoder_gets_correct_gc_content(sequence, encoder_3bit)[source]
sctools.test.test_entrypoints module
sctools.test.test_fastq module
- sctools.test.test_fastq.i7_files_compressions_and_modes(request)[source]
generates different compression types and modes for testing
- sctools.test.test_fastq.reader_all_compressions(request)[source]
generates open fastq reader files for each compression and read mode
- sctools.test.test_fastq.test_corrects_barcodes(barcode_generator_with_corrected_cell_barcodes)[source]
- sctools.test.test_fastq.test_embedded_barcode_generator_produces_outputs_of_expected_size(embedded_barcode_generator)[source]
- sctools.test.test_fastq.test_fastq_returns_correct_filesize_for_single_and_multiple_files()[source]
- sctools.test.test_fastq.test_printing_bytes_record_generates_valid_fastq_record(bytes_fastq_record)[source]
- sctools.test.test_fastq.test_printing_string_record_generates_valid_fastq_record(string_fastq_record)[source]
- sctools.test.test_fastq.test_reader_reads_correct_number_of_records_across_multiple_files(reader_all_compressions)[source]
- sctools.test.test_fastq.test_reader_skips_header_character_raises_value_error(i7_files_compressions_and_modes)[source]
- test should skip the first name line, shifting each record up 1. As a result, the
first sequence should be found in the name field
sctools.test.test_gtf module
sctools.test.test_metrics module
- sctools.test.test_metrics.split_metrics_file(metrics_file)[source]
produces two mergeable on-disk metric files from a single file that contain the first 3/4 of the file in the first output and the last 3/4 of the file in the second output, such that 1/2 of the metrics in the two files overlap
- sctools.test.test_metrics.test_calculate_cell_metrics_cli()[source]
test the sctools cell metrics CLI invocation
- sctools.test.test_metrics.test_calculate_gene_metrics_cli()[source]
test the sctools gene metrics CLI invocation
- sctools.test.test_metrics.test_cell_metrics_mean_n_genes_observed()[source]
test that the GatherCellMetrics method identifies the correct number of genes per cell, on average.
- sctools.test.test_metrics.test_duplicate_records(metrics, expected_value)[source]
Duplicate records are identified by the 1024 bit being set in the sam flag
- sctools.test.test_metrics.test_fragments_number_is_greater_than_molecule_number(metrics)[source]
There should always be more fragments than molecules, as the minimum definition of a molecule is a fragment covered by a single read
- sctools.test.test_metrics.test_gene_metrics_n_genes()[source]
Test that GatherGeneMetrics identifies the total number of genes in the test file
- sctools.test.test_metrics.test_gzip_compression(bam: str, gatherer: Callable)[source]
gzip compression should produce a .gz file which is identical when uncompressed to the uncompressed version
- sctools.test.test_metrics.test_higher_order_metrics_by_gene(metrics, key, expected_value)[source]
Test metrics that depend on other metrics
This class tests a very large number of higher-order metrics that examine the functionality of the test suite across all measured instances of the metric class. E.g. for cell metrics (class), each test will verify the value for each cell (instance).
- Parameters
metrics (pd.DataFrame) – Output from subclass of sctools.metrics.MetricAggregator
key (str) – The column of metrics to interrogate in the parametrized test
expected_value (np.ndarray) – An array of expected values
- sctools.test.test_metrics.test_merge_cell_metrics_cli(mergeable_cell_metrics)[source]
test the sctools merge cell metrics CLI invocation
- sctools.test.test_metrics.test_merge_cell_metrics_does_not_correct_duplicates(mergeable_cell_metrics)[source]
test takes offset cell metrics outputs and merges them. Cell metrics does not check for duplication, so should return a 2x length file.
- sctools.test.test_metrics.test_merge_gene_metrics_averages_over_multiply_detected_genes(mergeable_gene_metrics)[source]
- sctools.test.test_metrics.test_merge_gene_metrics_cli(mergeable_gene_metrics)[source]
test the sctools merge gene metrics CLI invocation
- sctools.test.test_metrics.test_metrics_highest_expression_class(metrics, expected_value)[source]
for gene metrics, this is the highest expression gene. For cell metrics, this is the highest expression cell.
- sctools.test.test_metrics.test_metrics_highest_read_count(metrics, expected_value)[source]
Test that each metric identifies the what the highest read count associated with any single entity
- sctools.test.test_metrics.test_metrics_n_fragments(metrics, expected_value)[source]
Test that each metric identifies the total number of fragments in the test file.
Fragments are defined as a unique combination of {cell barcode, molecule barcode, strand, position, chromosome}
- sctools.test.test_metrics.test_metrics_n_molecules(metrics, expected_value)[source]
Test that each metric identifies the total number of molecules in the test file
Molecules are defined as a unique combination of {cell barcode, molecule barcode, gene}
- sctools.test.test_metrics.test_metrics_n_reads(metrics, expected_value)[source]
test that the metrics identify the correct read number
- sctools.test.test_metrics.test_metrics_number_perfect_cell_barcodes(metrics, expected_value)[source]
Test that each metric correctly identifies the number of perfect cell barcodes where CB == CR
- sctools.test.test_metrics.test_metrics_number_perfect_molecule_barcodes(metrics, expected_value)[source]
Test that each metric correctly identifies the number of perfect molecule barcodes where UB == UR
- sctools.test.test_metrics.test_reads_mapped_exonic(metrics, expected_value)[source]
Test that each metric identifies the number of reads mapped to an exon (XF==’CODING’)
- sctools.test.test_metrics.test_reads_mapped_intronic(metrics, expected_value)[source]
Test that each metric identifies the number of reads mapped to an intron (XF==’INTRONIC’)
- sctools.test.test_metrics.test_reads_mapped_uniquely(metrics, expected_value)[source]
Uniquely mapping reads will be tagged with NH==1
- sctools.test.test_metrics.test_reads_mapped_utr(metrics, expected_value)[source]
Test that each metric identifies the number of reads mapped to a UTR (XF==’UTR’)