def test_headerfile_create_with_trypath(self): header = testutil.datafile('prefixUnionDict-1.txt') db = PrefixUnionDict(filename=header, trypath=[os.path.dirname(header)]) try: assert len(db) == 2, db.prefixDict finally: close_pud_dicts(db)
def test_headerfile_create(self): header = testutil.datafile('prefixUnionDict-1.txt') db = PrefixUnionDict(filename=header) try: assert len(db) == 2 assert 'a.seq1' in db finally: close_pud_dicts(db)
def test_funny_key2(self): "check handling of ID containing multiple separators" dnaseq = testutil.datafile('funnyseq.fasta') seqdb = SequenceFileDB(dnaseq) # contains 'seq1', 'seq2' try: pudb = PrefixUnionDict({'prefix': seqdb}) seq = pudb['prefix.seq.2.even.longer'] finally: seqdb.close()
def test_headerfile_create_fail(self): header = testutil.datafile('prefixUnionDict-3.txt') try: db = PrefixUnionDict(filename=header) assert 0, "should not reach this point" except IOError: pass except AssertionError: close_pud_dicts(db) raise
def test_headerfile_write(self): header = testutil.datafile('prefixUnionDict-2.txt') db = PrefixUnionDict(filename=header) try: assert len(db) == 4 assert 'a.seq1' in db assert 'b.seq1' in db output = testutil.tempdatafile('prefixUnionDict-write.txt') db.writeHeaderFile(output) finally: close_pud_dicts(db) db2 = PrefixUnionDict(filename=output, trypath=[os.path.dirname(header)]) try: assert len(db2) == 4 assert 'a.seq1' in db2 assert 'b.seq1' in db2 finally: close_pud_dicts(db2)
def test_headerfile_create_conflict(self): "test non-empty prefixDict with a passed in PUD header file: conflict" subdb = SequenceFileDB(self.dbfile) try: header = testutil.datafile('prefixUnionDict-1.txt') try: db = PrefixUnionDict(filename=header, prefixDict={'foo': subdb}) assert 0, "should not get here" except TypeError: pass finally: subdb.close()
def test_headerfile_write_fail(self): subdb = SequenceFileDB(self.dbfile) try: del subdb.filepath # remove 'filepath' attribute for test db = PrefixUnionDict({'prefix': subdb}) assert len(db) == 2 assert 'prefix.seq1' in db output = testutil.tempdatafile('prefixUnionDict-write-fail.txt') try: db.writeHeaderFile(output) except AttributeError: pass finally: subdb.close() # closes both db and subdb
def setUp(self): dnaseq = testutil.datafile('dnaseq.fasta') seqdb = SequenceFileDB(dnaseq) # contains 'seq1', 'seq2' self.db = PrefixUnionDict({'prefix': seqdb}) self.mdb = self.db.newMemberDict()
def test_empty_create(self): db = PrefixUnionDict() assert len(db) == 0