def test_add_link(self): '''Tests add_link method.''' dna1 = _read('sbol.xml') dna2 = _read('sbol2.xml') ice_entry1 = ICEEntry(typ='PLASMID', dna=dna1) self.__ice_client.set_ice_entry(ice_entry1) ice_entry2 = ICEEntry(typ='PLASMID', dna=dna2) self.__ice_client.set_ice_entry(ice_entry2) self.__ice_client.add_link( ice_entry1.get_ice_number(), ice_entry2.get_ice_number()) # "Refresh" (update metadata) ice_entry1 = self.__ice_client.get_ice_entry(ice_entry1.get_ice_id()) ice_entry2 = self.__ice_client.get_ice_entry(ice_entry2.get_ice_id()) self.assertTrue(ice_entry1.get_ice_number() in [par['id'] for par in ice_entry2.get_metadata()['parents']]) self.assertTrue(ice_entry2.get_ice_number() in [link['id'] for link in ice_entry1.get_metadata()['linkedParts']])
def write_ice_entry(ice_client, ice_id1, ice_id2, typ, write_seq, group_names): '''Write a composite ICE entry (part in plasmid, or plasmid in strain).''' comp1 = ice_client.get_ice_entry(ice_id1) comp2 = ice_client.get_ice_entry(ice_id2) name = comp1.get_metadata()['name'] + \ ' (' + comp2.get_metadata()['name'] + ')' product = ICEEntry(typ=typ) product.set_values({'name': name[:127], 'shortDescription': name}) taxonomy = comp1.get_parameter('Taxonomy') if taxonomy: product.set_parameter('Taxonomy', taxonomy) ice_client.set_ice_entry(product) ice_client.add_link(product.get_ice_id(), comp1.get_ice_id()) ice_client.add_link(product.get_ice_id(), comp2.get_ice_id()) if write_seq: product.set_dna(dna_utils.concat( [comp1.get_dna(), comp2.get_dna()])) ice_client.set_ice_entry(product) if group_names: groups = ice_client.get_groups() for group_name in group_names: ice_client.add_permission(product.get_ice_id(), groups[group_name]) return product, comp1, comp2
def __write_dominoes(self, design): '''Writes dominoes to ICE, or retrieves them if pre-existing.''' seq_entries = {} for domino in design['dominoes']: seq = domino[1][0][0] + domino[1][1][0] if seq in seq_entries: ice_entry = seq_entries[seq] else: ice_entries = self.__ice_client.get_ice_entries_by_seq(seq) if len(ice_entries) == 0: dna = _get_domino_dna('name', seq, domino[1][0][0], domino[1][1][0]) ice_entry = ICEEntry(dna, 'PART') else: ice_entry = ice_entries[0] name, description = self.__get_metadata(ice_entry, domino[0]) _set_metadata(ice_entry, name, description, 'DOMINO') self.__ice_client.set_ice_entry(ice_entry) self.__add_permissions(ice_entry) # Add link from plasmid -> domino: self.__ice_client.add_link( design['ice_id'], ice_entry.get_ice_id()) seq_entries[seq] = ice_entry
def test_set_get_parameter(self): '''Tests set/get_parameter method.''' ice_entry = ICEEntry(typ='PLASMID') ice_entry.set_parameter('Cheese', 'Brie') self.__ice_client.set_ice_entry(ice_entry) ice_entry = self.__ice_client.get_ice_entry(ice_entry.get_ice_id()) self.assertEqual(ice_entry.get_parameter('Cheese'), 'Brie')
def test_get_seq(self): '''Tests get_seq method.''' dna = _read('sbol.xml') ice_entry = ICEEntry(typ='PLASMID', dna=dna) self.__ice_client.set_ice_entry(ice_entry) ice_entry = self.__ice_client.get_ice_entry(ice_entry.get_ice_id()) self.assertEqual(ice_entry.get_seq(), dna['seq'])
def test_add_permission(self): '''Tests add_permission method.''' dna = _read('sbol.xml') ice_entry = ICEEntry(typ='PLASMID', dna=dna) self.__ice_client.set_ice_entry(ice_entry) groups = self.__ice_client.get_groups() for group_num in groups.values(): self.__ice_client.add_permission(ice_entry.get_ice_id(), group_num) # If test progresses to here, it has succeeded: self.assertTrue(True)
def test_add_link(self): '''Tests add_link method.''' dna1 = _read('sbol.xml') dna2 = _read('sbol2.xml') ice_entry1 = ICEEntry(typ='PLASMID', dna=dna1) self.__ice_client.set_ice_entry(ice_entry1) ice_entry2 = ICEEntry(typ='PLASMID', dna=dna2) self.__ice_client.set_ice_entry(ice_entry2) self.__ice_client.add_link(ice_entry1.get_ice_number(), ice_entry2.get_ice_number()) # "Refresh" (update metadata) ice_entry1 = self.__ice_client.get_ice_entry(ice_entry1.get_ice_id()) ice_entry2 = self.__ice_client.get_ice_entry(ice_entry2.get_ice_id()) self.assertTrue(ice_entry1.get_ice_number( ) in [par['id'] for par in ice_entry2.get_metadata()['parents']]) self.assertTrue(ice_entry2.get_ice_number( ) in [link['id'] for link in ice_entry1.get_metadata()['linkedParts']])
def __write_plasmid(self, design): '''Writes plasmids to ICE.''' ice_entry = ICEEntry(typ='PLASMID') self.__ice_client.set_ice_entry(ice_entry) self.__add_permissions(ice_entry) design['ice_id'] = ice_entry.get_ice_id() _set_metadata(ice_entry, design['name'], ' '.join(design['design']), 'PLASMID') ice_entry.set_dna(design['plasmid']) self.__ice_client.set_ice_entry(ice_entry) # Add link from plasmid -> parts: for part_id in design['design']: self.__ice_client.add_link(design['ice_id'], part_id)