def make_seqrepo(writeable): sr = SeqRepo("/tmp/sr", writeable=True) sr.store("SMELLASSWEET", [{"namespace": "en", "alias": "rose"}, {"namespace": "fr", "alias": "rose"}]) if writeable is False: del sr sr = SeqRepo("/tmp/sr", writeable=writeable) print("pid {pid} created {sr}".format(pid=os.getpid(), sr=sr)) return sr
def test_refseq_translation(tmpdir_factory): dir = str(tmpdir_factory.mktemp('seqrepo')) seqrepo = SeqRepo(dir, writeable=True) seqrepo.store("NCBISEQUENCE", [{"namespace": "NCBI", "alias": "ncbiac"}]) seqrepo.commit() del seqrepo seqrepo = SeqRepo(dir, writeable=False, translate_ncbi_namespace=False) aliases = list(seqrepo.aliases.find_aliases(alias="ncbiac")) assert len(aliases) == 1 assert aliases[0]["namespace"] == "NCBI" seqrepo = SeqRepo(dir, writeable=False, translate_ncbi_namespace=True) aliases = list(seqrepo.aliases.find_aliases(alias="ncbiac")) assert len(aliases) == 1 assert aliases[0]["namespace"] == "RefSeq"