Exemple #1
0
    def setUp(self,**kwargs):
        TestBase.setUp(self)
        dnaseq = testutil.datafile('dnaseq.fasta')
        tryannot = testutil.tempdatafile('tryannot')

        db = seqdb.BlastDB(dnaseq)
        try:
            db.__doc__ = 'little dna'

            pygrData.Bio.Test.dna = db
            annoDB = seqdb.AnnotationDB({1:('seq1',5,10,'fred'),
                                         2:('seq1',-60,-50,'bob'),
                                         3:('seq2',-20,-10,'mary')},
                                        db,
                                  sliceAttrDict=dict(id=0, start=1, stop=2,
                                                     name=3))
            annoDB.__doc__ = 'trivial annotation'
            pygrData.Bio.Test.annoDB = annoDB
            nlmsa = cnestedlist.NLMSA(tryannot,'w',pairwiseMode=True,
                                      bidirectional=False)
            try:
                for annID in annoDB:
                    nlmsa.addAnnotation(annoDB[annID])

                nlmsa.build(verbose=False)
                nlmsa.__doc__ = 'trivial map'
                pygrData.Bio.Test.map = nlmsa
                pygrSchema.Bio.Test.map = metabase.ManyToManyRelation(db,
                                                       annoDB,bindAttrs=('exons',))
                pygrData.commit()
                pygrData.clear_cache()
            finally:
                nlmsa.close()
        finally:
            db.close()
Exemple #2
0
    def test_schema(self):
        "Test schema"
        sp_hbb1 = testutil.datafile('sp_hbb1') 
        sp2 = seqdb.BlastDB(sp_hbb1)
        sp2.__doc__ = 'another sp'
        pygrData.Bio.Seq.sp2 = sp2
        sp = pygrData.Bio.Seq.Swissprot.sp42()
        m = mapping.Mapping(sourceDB=sp,targetDB=sp2)
        m.__doc__ = 'sp -> sp2'
        pygrData.Bio.Seq.testmap = m
        pygrSchema.Bio.Seq.testmap = metabase.OneToManyRelation(sp, sp2)
        pygrData.commit()

        pygrData.clear_cache()

        sp3 = seqdb.BlastDB(sp_hbb1)
        sp3.__doc__ = 'sp number 3'
        pygrData.Bio.Seq.sp3 = sp3
        sp2 = pygrData.Bio.Seq.sp2()
        m = mapping.Mapping(sourceDB=sp3,targetDB=sp2)
        m.__doc__ = 'sp3 -> sp2'
        pygrData.Bio.Seq.testmap2 = m
        pygrSchema.Bio.Seq.testmap2 = metabase.OneToManyRelation(sp3, sp2)
        l = pygrData._mdb.resourceCache.keys()
        l.sort()
        assert l == ['Bio.Seq.sp2', 'Bio.Seq.sp3', 'Bio.Seq.testmap2']
        pygrData.commit()
        g = pygrData._mdb.writer.storage.graph
        expected = set(['Bio.Annotation.annoDB',
                     'Bio.Seq.Swissprot.sp42', 'Bio.Seq.sp2', 'Bio.Seq.sp3'])
        found = set(g.keys()) 
        self.EQ(len(expected - found), 0) 
Exemple #3
0
    def setUp(self):
        TestBase.setUp(self)
        populate_swissprot() # save some data
        pygrData.commit() # finally save everything to metabase
        pygrData.clear_cache() # force all requests to reload

        res = [ 'Bio.Seq.Swissprot.sp42', 'Bio.Seq.frag', 'Bio.Seq.spmap',
                'Bio.Annotation.annoDB', 'Bio.Annotation.map' ]
        self.server = testutil.TestXMLRPCServer(res, self.tempdir.path)
Exemple #4
0
    def test_download(self): 
        "Downloading of gzipped file using pygr.Data"
        
        url = SourceURL('http://www.doe-mbi.ucla.edu/~leec/test.gz')
        url.__doc__ = 'test download'

        pygrData.add_resource('Bio.Test.Download1', url)
        pygrData.commit()

        # performs the download            
        fpath = pygrData.Bio.Test.Download1()
        h = testutil.get_file_md5(fpath)
        self.assertEqual(h.hexdigest(), 'f95656496c5182d6cff9a56153c9db73')
        os.remove(fpath)
Exemple #5
0
 def test_xmlrpc(self):
     "Test XMLRPC"
     pygrData.clear_cache() # force all future requests to reload
     pygrData.update("http://localhost:%s" % self.server.port) # from XMLRPC
     
     check_match(self) # run all our tests
     check_dir(self)
     check_dir_noargs(self)
     check_dir_download(self)
     check_dir_re(self)
     check_bind(self)
     check_bind2(self)
     
     sb_hbb1 = testutil.datafile('sp_hbb1') # test readonly checks
     sp2 = seqdb.BlastDB(sb_hbb1)
     sp2.__doc__ = 'another sp'
     try:
         pygrData.Bio.Seq.sp2 = sp2
         pygrData.commit()
         msg = 'failed to catch bad attempt to write to XMLRPC server'
         raise KeyError(msg)
     except ValueError:
         pass
Exemple #6
0
 def setUp(self, *args, **kwargs):
     TestBase.setUp(self, *args, **kwargs)
     populate_swissprot()
     pygrData.commit() # finally save everything
     pygrData.clear_cache() # force all requests to reload