Beispiel #1
0
 def test_list_wrapping(self):
     # Ensure that at least certain properties handle automatic list
     # wrapping and are typed to do so.
     # See https://github.com/SynBioDex/pySBOL3/issues/301
     sbol3.set_namespace('https://github.com/synbiodex/pysbol3')
     seq = sbol3.Sequence('seq1')
     test_loc = sbol3.EntireSequence(seq)
     seq_feat1 = sbol3.SequenceFeature(locations=test_loc)
     self.assertEqual([test_loc], seq_feat1.locations)
Beispiel #2
0
 def test_cascade_identity(self):
     # Test that updating identity of an owned object cascades
     # to child owned objects
     sbol3.set_namespace('https://github.com/synbiodex/pysbol3')
     c1 = sbol3.Component('c1', sbol3.SBO_DNA)
     seq = sbol3.Sequence('seq1')
     loc = sbol3.EntireSequence(seq)
     seq_feature = sbol3.SequenceFeature([loc])
     c1.features.append(seq_feature)
     self.assertIsNotNone(seq_feature.identity)
     # identity should cascade down to the location after it
     # is set on the sequence feature
     self.assertIsNotNone(loc.identity)
Beispiel #3
0
 def test_recursive_validation(self):
     # Test that the owned object, in this case the Range,
     # is also validated when the SequenceFeature is validated.
     seq_uri = 'https://github.com/synbiodex/pysbol3/sequence'
     start = 10
     end = 1
     r = sbol3.Range(seq_uri, start, end)
     report = r.validate()
     # end < start is a validation error
     self.assertEqual(1, len(report.errors))
     sf = sbol3.SequenceFeature([r])
     report = sf.validate()
     # We should find the validation issue in the owned
     # object (the range).
     self.assertEqual(1, len(report.errors))
Beispiel #4
0
 def test_validate(self):
     # Test the document level validation
     # This should validate all the objects in the document
     # and return a report containing all errors and warnings.
     doc = sbol3.Document()
     c1 = sbol3.Component('https://github.com/synbiodex/pysbol3/c1',
                          sbol3.SBO_DNA)
     doc.add(c1)
     s1 = sbol3.Sequence('https://github.com/synbiodex/pysbol3/s1')
     doc.add(s1)
     start = 10
     end = 1
     r = sbol3.Range(s1, start, end)
     sf = sbol3.SequenceFeature([r])
     c1.features.append(sf)
     report = doc.validate()
     # We should find the validation issue in the Range
     self.assertEqual(1, len(report))
Beispiel #5
0
 def test_overwrite_identity(self):
     sbol3.set_namespace('https://github.com/synbiodex/pysbol3')
     c1 = sbol3.Component('c1', sbol3.SBO_DNA)
     seq = sbol3.Sequence('seq1')
     loc = sbol3.EntireSequence(seq)
     seq_feature = sbol3.SequenceFeature([loc])
     c1.features.append(seq_feature)
     self.assertIsNotNone(seq_feature.identity)
     # identity should cascade down to the location after it
     # is set on the sequence feature
     self.assertIsNotNone(loc.identity)
     old_sf_identity = seq_feature.identity
     old_loc_identity = loc.identity
     c2 = sbol3.Component('c2', sbol3.SBO_DNA)
     # Try adding the same object to a different parent
     # This should cause an error because the object is
     # still parented by c1.
     # See https://github.com/SynBioDex/pySBOL3/issues/178
     with self.assertRaises(ValueError):
         c2.features.append(seq_feature)
     self.assertEqual(old_loc_identity, loc.identity)
     self.assertEqual(old_sf_identity, seq_feature.identity)
Beispiel #6
0
 def test_validation(self):
     locations = []
     sf = sbol3.SequenceFeature(locations)
     report = sf.validate()
     self.assertIsNotNone(report)
     self.assertEqual(1, len(report.errors))
Beispiel #7
0
 def test_create(self):
     es1 = sbol3.EntireSequence(sbol3.PYSBOL3_MISSING)
     locations = [es1]
     sf = sbol3.SequenceFeature(locations)
     self.assertEqual(locations, sf.locations)