def read_data(self):
     try:
         data = UrlReader(self.URL).read()
     except Exception:
         data = self._read_cached_data()
         if data is None:
             return
     else:
         dir_path = local_cache_path(self.DIR_NAME)
         if not os.path.exists(dir_path):
             os.makedirs(dir_path)
         data.save(local_cache_path(self.FILE_NAME))
     self.set_source(data)
     self.commit()
Ejemplo n.º 2
0
                for dataset in mart.datasets():
                    print("\t\t Dataset '%s' %s' '%s'" % \
                          (dataset.datasetType, dataset.internalName,
                           dataset.displayName))
            except BioMartError as err:
                print(err, file=sys.stderr)

    reg = BioMartRegistry(con)

    dataset = reg.dataset("scerevisiae_gene_ensembl")
    query = BioMartQuery(
        con,
        dataset="scerevisiae_gene_ensembl",
        attributes=["ensembl_transcript_id", "transcript_exon_intron"],
        filters=[("chromosome_name", "I"), ("with_wikigene", {
            "excluded": "1"
        })],
        format="FASTA")
    print(query.xml_query())
    print(query.run())

    data = query.get_table()
    data.save("seq.tab")

    import doctest
    doctest.testmod(extraglobs={
        "connection": con,
        "registry": registry
    },
                    optionflags=doctest.ELLIPSIS)
Ejemplo n.º 3
0
    for schema in registry.virtual_schemas():
        print("Virtual schema '%s'" % schema.name)
        for mart in schema.databases():
            print("\tMart: '%s' ('%s'):" % (mart.name, mart.displayName))
            try:
                for dataset in mart.datasets():
                    print("\t\t Dataset '%s' %s' '%s'" % \
                          (dataset.datasetType, dataset.internalName,
                           dataset.displayName))
            except BioMartError as err:
                print(err, file=sys.stderr)

    reg = BioMartRegistry(con)

    dataset = reg.dataset("scerevisiae_gene_ensembl")
    query = BioMartQuery(
         con, dataset="scerevisiae_gene_ensembl",
         attributes=["ensembl_transcript_id", "transcript_exon_intron"],
         filters=[("chromosome_name", "I"),
                  ("with_wikigene", {"excluded": "1"})],
         format="FASTA")
    print(query.xml_query())
    print(query.run())

    data = query.get_table()
    data.save("seq.tab")

    import doctest
    doctest.testmod(extraglobs={"connection": con, "registry": registry},
                    optionflags=doctest.ELLIPSIS)