High-level description
This file contains unit tests for theerror_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 classTestErrorCorrectIntBCstoWhitelist 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 fromunittest.TestCase, containing setup and test methods for the error_correct_intbcs_to_whitelist function.
Internal Logic
- Sets up test data in the
setUpmethod, including a whitelist file path, a whitelist list, and a DataFrame with sample data. - Defines two test methods to verify the correction functionality.
setUp
Description
Initializes test data, including file paths, whitelist, and a sample DataFrame.Internal Logic
- Sets up file paths for test files.
- Creates a whitelist of integration barcodes.
- Generates a sample DataFrame with various columns including cellBC, UMI, readCount, Seq, intBC, etc.
- Adds ‘readName’ and ‘allele’ columns to the DataFrame.
- Defines a dictionary of expected corrections for intBCs.
test_correct
Description
Tests theerror_correct_intbcs_to_whitelist function using a file path for the whitelist.
Internal Logic
- Calls
cassiopeia.pp.error_correct_intbcs_to_whitelistwith the sample DataFrame and whitelist file path. - Creates an expected DataFrame by applying corrections to the intBC column.
- Compares the result with the expected DataFrame using
pd.testing.assert_frame_equal.
test_correct_whitelist_list
Description
Tests theerror_correct_intbcs_to_whitelist function using a list for the whitelist.
Internal Logic
- Calls
cassiopeia.pp.error_correct_intbcs_to_whitelistwith the sample DataFrame and whitelist list. - Creates an expected DataFrame by applying corrections to the intBC column.
- Compares the result with the expected DataFrame using
pd.testing.assert_frame_equal.
Dependencies
| Dependency | Purpose |
|---|---|
| os | File path operations |
| unittest | Unit testing framework |
| numpy | Not directly used in the code |
| pandas | Data manipulation and testing |
| cassiopeia | Package being tested |
