High-level description

This file contains unit tests for the error_correct_intbcs_to_whitelist function in the Cassiopeia package. The tests verify the functionality of correcting integration barcodes (intBCs) to a whitelist, using both a file path and a list as input for the whitelist.

Code Structure

The code defines a single test class TestErrorCorrectIntBCstoWhitelist with a setUp method to initialize test data and two test methods to verify the correction functionality.

Symbols

TestErrorCorrectIntBCstoWhitelist

Description

A test class that inherits from unittest.TestCase, containing setup and test methods for the error_correct_intbcs_to_whitelist function.

Internal Logic

  1. Sets up test data in the setUp method, including a whitelist file path, a whitelist list, and a DataFrame with sample data.
  2. Defines two test methods to verify the correction functionality.

setUp

Description

Initializes test data, including file paths, whitelist, and a sample DataFrame.

Internal Logic

  1. Sets up file paths for test files.
  2. Creates a whitelist of integration barcodes.
  3. Generates a sample DataFrame with various columns including cellBC, UMI, readCount, Seq, intBC, etc.
  4. Adds ‘readName’ and ‘allele’ columns to the DataFrame.
  5. Defines a dictionary of expected corrections for intBCs.

test_correct

Description

Tests the error_correct_intbcs_to_whitelist function using a file path for the whitelist.

Internal Logic

  1. Calls cassiopeia.pp.error_correct_intbcs_to_whitelist with the sample DataFrame and whitelist file path.
  2. Creates an expected DataFrame by applying corrections to the intBC column.
  3. Compares the result with the expected DataFrame using pd.testing.assert_frame_equal.

test_correct_whitelist_list

Description

Tests the error_correct_intbcs_to_whitelist function using a list for the whitelist.

Internal Logic

  1. Calls cassiopeia.pp.error_correct_intbcs_to_whitelist with the sample DataFrame and whitelist list.
  2. Creates an expected DataFrame by applying corrections to the intBC column.
  3. Compares the result with the expected DataFrame using pd.testing.assert_frame_equal.

Dependencies

DependencyPurpose
osFile path operations
unittestUnit testing framework
numpyNot directly used in the code
pandasData manipulation and testing
cassiopeiaPackage being tested

Error Handling

The code relies on the default error handling provided by the unittest framework. No specific error handling mechanisms are implemented in this test file.