def test_expansion(self): """Test basic expansion of combinatorial derivations""" doc = sbol3.Document() doc.read(os.path.join(TESTFILE_DIR, 'simple_library.nt')) sbol3.set_namespace('http://sbolstandard.org/testfiles') roots = list( sbol_utilities.expand_combinatorial_derivations. root_combinatorial_derivations(doc)) assert len( roots) == 1, f'Unexpected roots: {[r.identity for r in roots]}' derivative_collections = sbol_utilities.expand_combinatorial_derivations.expand_derivations( roots) assert not len(doc.validate()) assert len(doc.find('Round_1_order_collection').members) == 24 output_doc = sbol3.Document() for c in derivative_collections: copy_toplevel_and_dependencies(output_doc, c) assert not len(output_doc.validate()) temp_name = tempfile.mkstemp(suffix='.nt')[1] output_doc.write(temp_name, sbol3.SORTED_NTRIPLES) assert_files_identical( temp_name, os.path.join(TESTFILE_DIR, 'expanded_simple_library.nt'))
def test_custom_conversion(self): """Test if conversion works correctly when the config us used to change expected sheet structure""" wb = openpyxl.load_workbook(os.path.join( TESTFILE_DIR, 'nonstandard_simple_library.xlsx'), data_only=True) sbol3.set_namespace('http://sbolstandard.org/testfiles') config = { 'basic_parts_name': 'C2', 'basic_parts_description': 'A12', 'basic_first_row': 21, 'basic_role_col': 2, 'basic_notes_col': 3, 'basic_description_col': 5, 'basic_source_prefix_col': 6, 'basic_source_id_col': 7, 'basic_final_col': 10, 'basic_circular_col': 11, 'basic_length_col': 12, 'basic_sequence_col': 13, 'composite_first_part_col': 8 } doc = sbol_utilities.excel_to_sbol.excel_to_sbol(wb, config) assert not doc.validate().errors and not doc.validate().warnings assert len(doc.find('BasicParts').members) == 26 assert len(doc.find('CompositeParts').members) == 6 assert len(doc.find('LinearDNAProducts').members) == 2 assert len(doc.find('FinalProducts').members) == 2 temp_name = tempfile.mkstemp(suffix='.nt')[1] doc.write(temp_name, sbol3.SORTED_NTRIPLES) assert_files_identical(temp_name, os.path.join(TESTFILE_DIR, 'simple_library.nt'))
def test_commandline(self): """Test expansion of combinatorial derivations from command line""" temp_name = tempfile.mkstemp(suffix='.nt')[1] test_args = [ 'sbol-expand-derivations', '-vv', os.path.join(TESTFILE_DIR, 'simple_library.nt'), '-o', temp_name ] with patch.object(sys, 'argv', test_args): sbol_utilities.expand_combinatorial_derivations.main() assert_files_identical( temp_name, os.path.join(TESTFILE_DIR, 'expanded_simple_library.nt'))
def test_commandline(self): """Make sure function works correctly when run from the command line""" temp_name = tempfile.mkstemp(suffix='.nt')[1] test_args = [ 'excel-to-sbol', '-vv', os.path.join(TESTFILE_DIR, 'simple_library.xlsx'), '-o', temp_name, '-n', 'http://sbolstandard.org/testfiles' ] with patch.object(sys, 'argv', test_args): sbol_utilities.excel_to_sbol.main() assert_files_identical(temp_name, os.path.join(TESTFILE_DIR, 'simple_library.nt'))
def test_multi_backbone(self): """Check if generation works correclty when there is more than one backbone option""" wb = openpyxl.load_workbook(os.path.join(TESTFILE_DIR, 'two_backbones.xlsx'), data_only=True) sbol3.set_namespace('http://sbolstandard.org/testfiles') doc = sbol_utilities.excel_to_sbol.excel_to_sbol(wb) assert not doc.validate().errors and not doc.validate().warnings assert len(doc.find('BasicParts').members) == 9 assert len(doc.find('CompositeParts').members) == 2 assert len(doc.find('LinearDNAProducts').members) == 2 assert len(doc.find('FinalProducts').members) == 2 temp_name = tempfile.mkstemp(suffix='.nt')[1] doc.write(temp_name, sbol3.SORTED_NTRIPLES) assert_files_identical(temp_name, os.path.join(TESTFILE_DIR, 'two_backbones.nt'))
def test_constraints(self): """Check if constraints are generated correctly""" wb = openpyxl.load_workbook(os.path.join(TESTFILE_DIR, 'constraints_library.xlsx'), data_only=True) sbol3.set_namespace('http://sbolstandard.org/testfiles') doc = sbol_utilities.excel_to_sbol.excel_to_sbol(wb) assert not doc.validate().errors and not doc.validate().warnings assert len(doc.find('BasicParts').members) == 43 assert len(doc.find('CompositeParts').members) == 8 assert len(doc.find('LinearDNAProducts').members) == 2 assert len(doc.find('FinalProducts').members) == 2 temp_name = tempfile.mkstemp(suffix='.nt')[1] doc.write(temp_name, sbol3.SORTED_NTRIPLES) assert_files_identical( temp_name, os.path.join(TESTFILE_DIR, 'constraints_library.nt'))
def test_conversion(self): """Basic smoke test of Excel to SBOL3 conversion""" wb = openpyxl.load_workbook(os.path.join(TESTFILE_DIR, 'simple_library.xlsx'), data_only=True) sbol3.set_namespace('http://sbolstandard.org/testfiles') doc = sbol_utilities.excel_to_sbol.excel_to_sbol(wb) assert not doc.validate().errors and not doc.validate().warnings assert len(doc.find('BasicParts').members) == 26 assert len(doc.find('CompositeParts').members) == 6 assert len(doc.find('LinearDNAProducts').members) == 2 assert len(doc.find('FinalProducts').members) == 2 temp_name = tempfile.mkstemp(suffix='.nt')[1] doc.write(temp_name, sbol3.SORTED_NTRIPLES) assert_files_identical(temp_name, os.path.join(TESTFILE_DIR, 'simple_library.nt'))