def testOSTSequenceWDir(self): # OST sequence as input, with working dir should work query_seq = seq.CreateSequence('1AKE.B', 'MRIILLGAPGAGKGTQAQFIMEKYGIPQISTGDMLRA'+ 'AVKSGSELGKQAKDIMDAGKLVTDELVIALVKERIAQ'+ 'EDCRNGFLLDGFPRTIPQADAMKEAGINVDYVLEFDV'+ 'PDELIVDRIVGRRVHAPSGRVYHVKFNPPKVEGKDDV'+ 'TGEELTTRKDDQEETVRKRLVEYHQMTAPLIGYYYYS'+ 'KEAEAGNTKYAKVDGTKPVAEVRADLEKILG') tmpdir = tempfile.mkdtemp() self.hh = hhblits.HHblits(query_seq, self.hhroot, working_dir=tmpdir) self.assertEqual(self.hh.filename, os.path.join(tmpdir, 'query_hhblits.fasta')) self.assertEqual(self.hh.working_dir, tmpdir) self.hh.needs_cleanup = True
def testA3mToCSFileExists(self): # test A3mToCS to work with a given hhmake_file name query_seq = seq.CreateSequence('Test', 'VLSPADKTNVKAAWGKVGAHAGEYGAEA'+ 'LERMFLSFPTTKTYFPHFDLSHGSAQVKGHGKKVAD'+ 'ALTNAVAHVDDMPNALSALSDLHAHKLRVDPVNFKL'+ 'LSHCLLVTLAAHLPAEFTPAVHASLDKFLASVSTVL'+ 'TSKYR') self.hh = hhblits.HHblits(query_seq, self.hhroot) csfile = self.hh.A3MToCS("testfiles/testali.a3m", cs_file='testfiles/test.seq219', options={'-alphabet' : os.path.join(self.hh.hhlib_dir, 'data', 'cs219.lib')}) self.assertTrue(filecmp.cmp(csfile, 'testfiles/test.seq219'))
def testA3mToProfileWithoutFileName(self): # test A3mToProfile to work without a given hhmake_file name query_seq = seq.CreateSequence('Test', 'VLSPADKTNVKAAWGKVGAHAGEYGAEA'+ 'LERMFLSFPTTKTYFPHFDLSHGSAQVKGHGKKVAD'+ 'ALTNAVAHVDDMPNALSALSDLHAHKLRVDPVNFKL'+ 'LSHCLLVTLAAHLPAEFTPAVHASLDKFLASVSTVL'+ 'TSKYR') self.hh = hhblits.HHblits(query_seq, self.hhroot) hhfile = self.hh.A3MToProfile("testfiles/testali.a3m") with open(hhfile) as tfh: tlst = tfh.readlines() with open("testfiles/test.hmm") as efh: elst = efh.readlines() self.assertEqual(len(elst), len(tlst)) for i in range(0, len(elst)): if not elst[i].startswith(('FILE', 'COM', 'DATE')): self.assertEqual(elst[i], tlst[i]) os.remove(hhfile)
def testSearchWorking(self): # successful search query_seq = seq.CreateSequence('Test', 'VLSPADKTNVKAAWGKVGAHAGEYGAEA'+ 'LERMFLSFPTTKTYFPHFDLSHGSAQVKGHGKKVAD'+ 'ALTNAVAHVDDMPNALSALSDLHAHKLRVDPVNFKL'+ 'LSHCLLVTLAAHLPAEFTPAVHASLDKFLASVSTVL'+ 'TSKYR') self.hh = hhblits.HHblits(query_seq, self.hhroot) search_file = self.hh.Search("testfiles/testali.a3m", 'testfiles/hhblitsdb/hhblitsdb') with open(search_file) as tfh: tlst = tfh.readlines() with open("testfiles/test.hhr") as efh: elst = efh.readlines() self.assertEqual(len(elst), len(tlst)) for i in range(0, len(elst)): if not elst[i].startswith(('Date', 'Command')): self.assertEqual(elst[i], tlst[i])
def testFileNoWDir(self): # we have a sequence but no working dir self.hh = hhblits.HHblits('testfiles/seq2.fasta', self.hhroot) self.assertEqual(self.hh.filename[-10:], 'seq2.fasta')
def testFileNoExists(self): # test on calling with a non-existing fasta file with self.assertRaises(IOError) as ioe: hhblits.HHblits('notthere.fasta', self.hhroot) self.assertEqual(ioe.exception.errno, 2) self.assertEqual(ioe.exception.strerror, 'No such file or directory')