def test_software(self): """Test Software class""" s1 = ihm.Software(name='foo', version='1.0', classification='1', description='2', location='3') s2 = ihm.Software(name='foo', version='2.0', classification='4', description='5', location='6') s3 = ihm.Software(name='foo', version='1.0', classification='7', description='8', location='9') s4 = ihm.Software(name='bar', version='1.0', classification='a', description='b', location='c') # Should compare equal iff name and version both match self.assertEqual(s1, s3) self.assertEqual(hash(s1), hash(s3)) self.assertNotEqual(s1, s2) self.assertNotEqual(s1, s4)
def test_all_citations(self): """Test _all_citations() method""" class MockObject(object): pass c1 = ihm.Citation(title='Test paper', journal='J Mol Biol', volume=45, page_range=(1, 20), year=2016, authors=['Smith A', 'Jones B'], doi='10.2345/S1384107697000225', pmid='1234') c2 = ihm.Citation(title='Test paper', journal='J Mol Biol', volume=45, page_range=(1, 20), year=2016, authors=['Smith A', 'Jones B'], doi='1.2.3.4', pmid='1234') c3 = ihm.Citation(title='Test paper2', journal='J Mol Biol2', volume=46, page_range=(1, 20), year=2017, authors=['Smith A', 'Jones B'], doi='5.6.7.8', pmid='5678') rsr1 = MockObject() # Not a 3dem restraint rsr2 = MockObject() # 3dem but with no provided citation rsr2.fitting_method_citation_id = None rsr3 = MockObject() rsr2.fitting_method_citation_id = c1 s1 = ihm.Software(name='test', classification='test code', description='Some test program', version=1, location='http://test.org') s2 = ihm.Software(name='test', classification='test code', description='Some test program', version=1, location='http://test.org', citation=c3) s = ihm.System() s.restraints.extend((rsr1, rsr2, rsr3)) s.citations.extend((c2, c2)) s.software.extend((s1, s2)) # duplicates should be filtered globally self.assertEqual(list(s._all_citations()), [c2, c3, c1])
def test_all_software(self): """Test _all_software() method""" class MockObject(object): pass s1 = ihm.Software(name='test', classification='test code', description='Some test program', version=1, location='http://test.org') s2 = ihm.Software(name='foo', classification='test code', description='Other test program', location='http://test2.org') sm1 = MockObject() sm1.software = None sm2 = MockObject() sm2.software = s1 s = ihm.System() s.orphan_starting_models.extend((sm1, sm2)) s.software.extend((s2, s2)) step1 = MockObject() step2 = MockObject() step1.software = None step2.software = s2 protocol1 = MockObject() protocol1.steps = [step1, step2] analysis1 = MockObject() astep1 = MockObject() astep1.software = s2 analysis1.steps = [astep1] protocol1.analyses = [analysis1] s.orphan_protocols.append(protocol1) r1 = MockObject() r2 = MockObject() r3 = MockObject() r2.software = None r3.software = s1 s.restraints.extend((r1, r2, r3)) # duplicates are kept self.assertEqual(list(s._all_software()), [s2, s2, s1, s2, s2, s1])
def _parse_phyre_model(self, fh, first_line, local_file, filename, ret): # Model generated by Phyre2 s = ihm.Software( name='Phyre2', classification='protein homology modeling', description='Protein Homology/analogY Recognition ' 'Engine V 2.0', version='2.0', location='http://www.sbg.bio.ic.ac.uk/~phyre2/') ret['software'].append(s) self._handle_comparative_model(local_file, filename, ret)
def _parse_modeller_model(self, fh, first_line, local_file, filename, ret): version, date = first_line[38:].rstrip('\r\n').split(' ', 1) s = ihm.Software(name='MODELLER', classification='comparative modeling', description='Comparative modeling by satisfaction ' 'of spatial restraints, build ' + date, location='https://salilab.org/modeller/', version=version) ret['software'].append(s) self._handle_comparative_model(local_file, filename, ret)
def _parse_swiss_model(self, fh, first_line, local_file, filename, ret): # Model generated by SWISS-MODEL meta = _get_swiss_model_metadata(filename) s = ihm.Software( name='SWISS-MODEL', classification='protein homology modeling', description='SWISS-MODEL: homology modelling of protein ' 'structures and complexes, using %s engine' % meta.get('info', {}).get('ENGIN', 'unknown'), version=meta.get('info', {}).get('VERSN', ihm.unknown), location='https://swissmodel.expasy.org/') ret['software'].append(s) comp_model_ds = dataset.ComparativeModelDataset(local_file) ret['dataset'] = comp_model_ds ret['templates'] = self._add_swiss_model_templates( local_file, meta, comp_model_ds, ret)