def test_concat(self):
        '''Tests concat method.'''
        directory = os.path.dirname(os.path.realpath(__file__))
        dna2 = sbol_utils.read(os.path.join(directory, 'sbol2.xml'))
        dna3 = sbol_utils.read(os.path.join(directory, 'sbol3.xml'))
        concat_dna = test_sbol_utils.round_trip(dna_utils.concat([dna2, dna3]))

        self.assertFalse(concat_dna['features'][0]['forward'])

        self.assertEqual(len(dna2['features']) + len(dna3['features']),
                         len(concat_dna['features']))
    def test_concat(self):
        '''Tests concat method.'''
        directory = os.path.dirname(os.path.realpath(__file__))
        dna2 = sbol_utils.read(os.path.join(directory, 'sbol2.xml'))
        dna3 = sbol_utils.read(os.path.join(directory, 'sbol3.xml'))
        concat_dna = test_sbol_utils.round_trip(dna_utils.concat([dna2, dna3]))

        self.assertFalse(concat_dna['features'][0]['forward'])

        self.assertEqual(
            len(dna2['features']) + len(dna3['features']),
            len(concat_dna['features']))
 def test_json(self):
     '''Tests json roundtrip.'''
     directory = os.path.dirname(os.path.realpath(__file__))
     dna1 = sbol_utils.read(os.path.join(directory, 'sbol.xml'))
     params = json.loads(json.dumps(dna1))
     dna2 = dna_utils.DNA(**params)
     self.assertEqual(dna1, dna2)
 def test_json(self):
     '''Tests json roundtrip.'''
     directory = os.path.dirname(os.path.realpath(__file__))
     dna1 = sbol_utils.read(os.path.join(directory, 'sbol.xml'))
     params = json.loads(json.dumps(dna1))
     dna2 = dna_utils.DNA(**params)
     self.assertEqual(dna1, dna2)
def _get_apply_restrict_site_dnas(restr, circ):
    '''Tests apply_restriction_site method.'''
    directory = os.path.dirname(os.path.realpath(__file__))
    par = sbol_utils.read(os.path.join(directory, 'restrict.xml'))
    return par, [
        test_sbol_utils.round_trip(dna)
        for dna in dna_utils.apply_restricts(par, [restr], circ)
    ]
    def __get_dna(self, ice_id):
        '''Gets the sequence ICE entry.'''
        url = self.__url + '/rest/file/' + self.__get_ice_number(ice_id) + \
            '/sequence/sbol1?sid=' + self.__sid
        temp_file = tempfile.NamedTemporaryFile(delete=False)

        with codecs.open(temp_file.name, 'w', 'utf-8') as text_file:
            text_file.write(net_utils.get(url))

        return sbol_utils.read(temp_file.name)
def _get_apply_restrict_site_dnas(restr, circ):
    '''Tests apply_restriction_site method.'''
    directory = os.path.dirname(os.path.realpath(__file__))
    par = sbol_utils.read(os.path.join(directory, 'restrict.xml'))
    return par, [test_sbol_utils.round_trip(dna)
                 for dna in dna_utils.apply_restricts(par, [restr], circ)]
 def test_copy(self):
     '''Tests copy method.'''
     directory = os.path.dirname(os.path.realpath(__file__))
     dna1 = sbol_utils.read(os.path.join(directory, 'sbol.xml'))
     dna2 = test_sbol_utils.round_trip(dna1.copy())
     self.assertEqual(dna1, dna2)
 def test_copy(self):
     '''Tests copy method.'''
     directory = os.path.dirname(os.path.realpath(__file__))
     dna1 = sbol_utils.read(os.path.join(directory, 'sbol.xml'))
     dna2 = test_sbol_utils.round_trip(dna1.copy())
     self.assertEqual(dna1, dna2)
def _read(filename):
    '''Reads sbol file.'''
    directory = os.path.dirname(os.path.realpath(__file__))
    return sbol_utils.read(os.path.join(directory, filename))
def _read(filename):
    '''Reads sbol file.'''
    directory = os.path.dirname(os.path.realpath(__file__))
    return sbol_utils.read(os.path.join(directory, filename))
Beispiel #12
0
def round_trip(dna):
    '''Writes / reads DNA object, via SBOL export / import.'''
    tmp = tempfile.NamedTemporaryFile()
    sbol_utils.write(dna, tmp.name)
    return sbol_utils.read(tmp.name)
Beispiel #13
0
 def test(self):
     '''Tests round trip equality.'''
     directory = os.path.dirname(os.path.realpath(__file__))
     dna1 = sbol_utils.read(os.path.join(directory, 'sbol.xml'))
     dna2 = round_trip(dna1)
     self.assertEqual(dna1, dna2)