Beispiel #1
0
def humanmine():
    for iden in gnomics.objects.auxiliary_files.identifier.filter_identifiers(gene.identifiers, ["humanmine primary id", "humanmine primary identifier", "humanmine primary gene id", "humanmine primary gene identifier"]):
    
        s = Service("www.humanmine.org/humanmine")
        Gene = s.model.Gene
        q = s.query(Gene).select("*").where("Gene", "LOOKUP", iden["identifier"])
        gene_object = {}  
        for row in q.rows():
            process = row.__str__()
            for x in re.findall(r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})", process):

                temp_str = x[1]
                if temp_str[0] == "'" and temp_str[-1] == "'":
                    temp_str = temp_str[1:-1]
                    
                if x[0] == "description":
                    gene_object["description"] = temp_str.strip()
                elif x[0] == "cytoLocation":
                    gene_object["cytogenetic_location"] = temp_str.strip()
                elif x[0] == "id":
                    gene_object["id"] = temp_str.strip()
                elif x[0] == "length":
                    gene_object["length"] = temp_str.strip()
                elif x[0] == "primaryIdentifier":
                    gene_object["primary_id"] = temp_str.strip()
                elif x[0] == "score":
                    gene_object["score"] = temp_str.strip()
                elif x[0] == "scoreType":
                    gene_object["score_type"] = temp_str.strip()
                elif x[0] == "secondaryIdentifier":
                    gene_object["secondary_id"] = temp_str.strip()
                elif x[0] == "symbol":
                    gene_object["symbol"] = temp_str.strip()
                        
        return gene_object
Beispiel #2
0
def ratmine(gene):
    for iden in gnomics.objects.auxiliary_files.identifier.filter_identifiers(
            gene.identifiers, [
                "ratmine primary id", "ratmine primary identifier",
                "ratmine primary gene id", "ratmine primary gene identifier"
            ]):

        s = Service("http://ratmine.mcw.edu/ratmine")
        Gene = s.model.Gene
        q = s.query(Gene).select("*").where("Gene", "LOOKUP",
                                            iden["identifier"])
        gene_object = {}
        for row in q.rows():
            process = row.__str__()
            for x in re.findall(
                    r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})",
                    process):

                temp_str = x[1]
                if temp_str[0] == "'" and temp_str[-1] == "'":
                    temp_str = temp_str[1:-1]

                if x[0] == "briefDescription":
                    if temp_str.strip() == "None":
                        gene_object["brief_description"] = None
                    else:
                        gene_object["brief_description"] = temp_str.strip()
                elif x[0] == "description":
                    gene_object["description"] = temp_str.strip()
                elif x[0] == "geneType":
                    gene_object["gene_type"] = temp_str.strip()
                elif x[0] == "id":
                    gene_object["id"] = temp_str.strip()
                elif x[0] == "length":
                    gene_object["length"] = temp_str.strip()
                elif x[0] == "name":
                    gene_object["name"] = temp_str.strip()
                elif x[0] == "ncbi_gene_number":
                    gene_object["ncbiGeneNumber"] = temp_str.strip()
                elif x[0] == "pharmGKBidentifier":
                    gene_object["pharmGKB_id"] = temp_str.strip()
                elif x[0] == "primaryIdentifier":
                    gene_object["primary_id"] = temp_str.strip()
                elif x[0] == "score":
                    gene_object["score"] = temp_str.strip()
                elif x[0] == "scoreType":
                    gene_object["score_type"] = temp_str.strip()
                elif x[0] == "secondaryIdentifier":
                    gene_object["secondary_id"] = temp_str.strip()
                elif x[0] == "symbol":
                    gene_object["symbol"] = temp_str.strip()

        return gene_object
    def attack(self):
        username = "******".format(self.ident)
        password = "******"

        try:
            s = Service(self.service.root, username, password)
            s.deregister(s.get_deregistration_token())
            self.counter.add(3)
        except:
            pass

        s = self.service.register(username, password)
        self.LOG.debug("Registered user " + username)
        self.counter.add(1)

        c = 0
        classes = s.model.classes.values()
        self.counter.add(1)

        classkeys = s._get_json('/classkeys')['classes']
        self.counter.add(1)

        while c == 0:
            table = random.choice(classes)
            if not (table.has_id and table.name in classkeys):
                continue
            query = s.query(table.name).select(classkeys[table.name][0])

            c = query.count()
            self.counter.add(1)

        n = random.randint(1, min(100, c))
        members = random.sample(map(lambda r: r[0], query.rows()), n)
        self.counter.add(1)

        self.LOG.debug("Will construct list of %s with: %r", table.name, members)

        with s.list_manager() as lm:
            l = lm.create_list(members, table.name)
            self.LOG.debug('Created list %s, size: %d', l.name, l.size)
            self.counter.add(1)

        try:
            s.deregister(s.get_deregistration_token())
            self.counter.add(2)
        except:
            pass
Beispiel #4
0
def flymine(gene):
    obj_array = []

    for ident in gene.identifiers:
        if ident["identifier_type"].lower() in [
                "ensembl", "ensembl id", "ensembl identifier",
                "ensembl gene id"
        ]:
            s = Service("www.flymine.org/query")
            Gene = s.model.Gene
            q = s.query(Gene).select("*").where("Gene", "LOOKUP",
                                                ident["identifier"])
            try:
                for row in q.rows():
                    primary_identifier = row["primaryIdentifier"]
                    brief_description = row["briefDescription"]
                    cyto_location = row["cytoLocation"]
                    description = row["description"]
                    identifier = row["id"]
                    length_of_gene = row["length"]
                    name_of_gene = row["name"]
                    score = row["score"]
                    score_type = row["scoreType"]
                    secondary_identifier = row["secondaryIdentifier"]
                    gene_symbol = row["symbol"]

                    gene_object = {
                        'id': identifier,
                        'primary_id': primary_identifier,
                        'secondary_id': secondary_identifier,
                        'symbol': gene_symbol,
                        'name': name_of_gene,
                        'cyto_location': cyto_location,
                        'brief_description': brief_description,
                        'description': description,
                        'length': length_of_gene,
                        'score': score,
                        'score_type': score_type
                    }
                    obj_array.append(gene_object)
            except intermine.errors.WebserviceError:
                print(
                    "A webservice error occurred. Please contact Intermine support."
                )
            else:
                print("Something else went wrong.")
    return obj_array
Beispiel #5
0
def ratmine(gene):
    for iden in gnomics.objects.auxiliary_files.identifier.filter_identifiers(gene.identifiers, ["ratmine primary id", "ratmine primary identifier", "ratmine primary gene id", "ratmine primary gene identifier"]):
    
        s = Service("http://ratmine.mcw.edu/ratmine")
        Gene = s.model.Gene
        q = s.query(Gene).select("*").where("Gene", "LOOKUP", iden["identifier"])
        gene_object = {}  
        for row in q.rows():
            process = row.__str__()
            for x in re.findall(r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})", process):

                temp_str = x[1]
                if temp_str[0] == "'" and temp_str[-1] == "'":
                    temp_str = temp_str[1:-1]
                    
                if x[0] == "briefDescription":
                    if temp_str.strip() == "None":
                        gene_object["brief_description"] = None
                    else:
                        gene_object["brief_description"] = temp_str.strip()
                elif x[0] == "description":
                    gene_object["description"] = temp_str.strip()
                elif x[0] == "geneType":
                    gene_object["gene_type"] = temp_str.strip()
                elif x[0] == "id":
                    gene_object["id"] = temp_str.strip()
                elif x[0] == "length":
                    gene_object["length"] = temp_str.strip()
                elif x[0] == "name":
                    gene_object["name"] = temp_str.strip()
                elif x[0] == "ncbi_gene_number":
                    gene_object["ncbiGeneNumber"] = temp_str.strip()
                elif x[0] == "pharmGKBidentifier":
                    gene_object["pharmGKB_id"] = temp_str.strip()
                elif x[0] == "primaryIdentifier":
                    gene_object["primary_id"] = temp_str.strip()
                elif x[0] == "score":
                    gene_object["score"] = temp_str.strip()
                elif x[0] == "scoreType":
                    gene_object["score_type"] = temp_str.strip()
                elif x[0] == "secondaryIdentifier":
                    gene_object["secondary_id"] = temp_str.strip()
                elif x[0] == "symbol":
                    gene_object["symbol"] = temp_str.strip()
                        
        return gene_object
    def attack(self):
        service = Service(self.service.root)
        self.counter.add(2)

        lists = list(l for l in service.get_all_lists() if l.size and l.status == 'CURRENT')
        Lists.LOG.debug("%d lists", len(lists))
        self.counter.add(1)

        target = random.choice(lists)

        classkeys = None
        with closing(service.opener.open(service.root + "/classkeys")) as sock:
            classkeys = json.loads(sock.read())['classes']
            Lists.LOG.debug("Classkeys for %s are %r", target.name, classkeys[target.list_type])
            self.counter.add(1)

        q = service.query(target.list_type).where(target.list_type, 'IN', target.name)

        index = random.randint(0, target.size - 1)
        rand_member = next(q.rows(size = 1, start = index))
        self.counter.add(1)
        Lists.LOG.debug(rand_member)

        target_keys = classkeys[target.list_type]
        if target_keys:
            lu_q = q.where(target.list_type, 'LOOKUP', rand_member[target_keys[0]])
            Lists.LOG.debug("lookup q: %s", lu_q)
            Lists.LOG.debug("%s should be one", lu_q.count())
            self.counter.add(1)

        suitable_widgets = list(w for w in service.widgets.values() if w['widgetType'] == 'enrichment' and target.list_type in w['targets'])
        self.counter.add(1)

        if not suitable_widgets:
            return

        widget = random.choice(suitable_widgets)

        Lists.LOG.debug("Calculating %s of %s", widget['name'], target.name)
        enriched = list(target.calculate_enrichment(widget['name']))
        self.counter.add(1)

        if enriched:
            Lists.LOG.debug(enriched[0])
Beispiel #7
0
def wormmine(gene):
    for iden in gnomics.objects.auxiliary_files.identifier.filter_identifiers(
            gene.identifiers, [
                "wormmine primary id", "wormmine primary identifier",
                "wormmine primary gene id", "wormmine primary gene identifier"
            ]):

        s = Service("http://intermine.wormbase.org/tools/wormmine")
        Gene = s.model.Gene
        q = s.query(Gene).select("*").where("Gene", "LOOKUP",
                                            iden["identifier"])
        gene_object = {}
        for row in q.rows():
            process = row.__str__()
            for x in re.findall(
                    r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})",
                    process):

                temp_str = x[1]
                if temp_str[0] == "'" and temp_str[-1] == "'":
                    temp_str = temp_str[1:-1]

                if x[0] == "id":
                    gene_object["id"] = temp_str.strip()
                elif x[0] == "lastUpdated":
                    gene_object["last_updated"] = temp_str.strip()
                elif x[0] == "length":
                    gene_object["length"] = temp_str.strip()
                elif x[0] == "name":
                    gene_object["name"] = temp_str.strip()
                elif x[0] == "operon":
                    gene_object["operon"] = temp_str.strip()
                elif x[0] == "primary_id":
                    gene_object["primary_id"] = temp_str.strip()
                elif x[0] == "score":
                    gene_object["score"] = temp_str.strip()
                elif x[0] == "score_type":
                    gene_object["score_type"] = temp_str.strip()
                elif x[0] == "secondary_id":
                    gene_object["secondary_id"] = temp_str.strip()
                elif x[0] == "symbol":
                    gene_object["symbol"] = temp_str.strip()

        return gene_object
Beispiel #8
0
def humanmine():
    for iden in gnomics.objects.auxiliary_files.identifier.filter_identifiers(
            gene.identifiers,
        [
            "humanmine primary id", "humanmine primary identifier",
            "humanmine primary gene id", "humanmine primary gene identifier"
        ]):

        s = Service("www.humanmine.org/humanmine")
        Gene = s.model.Gene
        q = s.query(Gene).select("*").where("Gene", "LOOKUP",
                                            iden["identifier"])
        gene_object = {}
        for row in q.rows():
            process = row.__str__()
            for x in re.findall(
                    r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})",
                    process):

                temp_str = x[1]
                if temp_str[0] == "'" and temp_str[-1] == "'":
                    temp_str = temp_str[1:-1]

                if x[0] == "description":
                    gene_object["description"] = temp_str.strip()
                elif x[0] == "cytoLocation":
                    gene_object["cytogenetic_location"] = temp_str.strip()
                elif x[0] == "id":
                    gene_object["id"] = temp_str.strip()
                elif x[0] == "length":
                    gene_object["length"] = temp_str.strip()
                elif x[0] == "primaryIdentifier":
                    gene_object["primary_id"] = temp_str.strip()
                elif x[0] == "score":
                    gene_object["score"] = temp_str.strip()
                elif x[0] == "scoreType":
                    gene_object["score_type"] = temp_str.strip()
                elif x[0] == "secondaryIdentifier":
                    gene_object["secondary_id"] = temp_str.strip()
                elif x[0] == "symbol":
                    gene_object["symbol"] = temp_str.strip()

        return gene_object
Beispiel #9
0
def flymine(gene):
    obj_array = []
    
    for ident in gene.identifiers:
        if ident["identifier_type"].lower() in ["ensembl", "ensembl id", "ensembl identifier", "ensembl gene id"]:
            s = Service("www.flymine.org/query")
            Gene = s.model.Gene
            q = s.query(Gene).select("*").where("Gene", "LOOKUP", ident["identifier"])
            try:
                for row in q.rows():
                    primary_identifier = row["primaryIdentifier"]
                    brief_description = row["briefDescription"]
                    cyto_location = row["cytoLocation"]
                    description = row["description"]
                    identifier = row["id"]
                    length_of_gene = row["length"]
                    name_of_gene = row["name"]
                    score = row["score"]
                    score_type = row["scoreType"]
                    secondary_identifier = row["secondaryIdentifier"]
                    gene_symbol = row["symbol"]

                    gene_object = {
                        'id': identifier,
                        'primary_id': primary_identifier,
                        'secondary_id': secondary_identifier,
                        'symbol': gene_symbol,
                        'name': name_of_gene,
                        'cyto_location': cyto_location,
                        'brief_description': brief_description,
                        'description': description,
                        'length': length_of_gene,
                        'score': score,
                        'score_type': score_type
                    }
                    obj_array.append(gene_object)
            except intermine.errors.WebserviceError:
                print("A webservice error occurred. Please contact Intermine support.")
            else:
                print("Something else went wrong.")
    return obj_array
Beispiel #10
0
def wormmine(gene):
    for iden in gnomics.objects.auxiliary_files.identifier.filter_identifiers(gene.identifiers, ["wormmine primary id", "wormmine primary identifier", "wormmine primary gene id", "wormmine primary gene identifier"]):
    
        s = Service("http://intermine.wormbase.org/tools/wormmine")
        Gene = s.model.Gene
        q = s.query(Gene).select("*").where("Gene", "LOOKUP", iden["identifier"])
        gene_object = {}  
        for row in q.rows():
            process = row.__str__()
            for x in re.findall(r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})", process):

                temp_str = x[1]
                if temp_str[0] == "'" and temp_str[-1] == "'":
                    temp_str = temp_str[1:-1]

                if x[0] == "id":
                    gene_object["id"] = temp_str.strip()
                elif x[0] == "lastUpdated":
                    gene_object["last_updated"] = temp_str.strip()
                elif x[0] == "length":
                    gene_object["length"] = temp_str.strip()
                elif x[0] == "name":
                    gene_object["name"] = temp_str.strip()
                elif x[0] == "operon":
                    gene_object["operon"] = temp_str.strip()
                elif x[0] == "primary_id":
                    gene_object["primary_id"] = temp_str.strip()
                elif x[0] == "score":
                    gene_object["score"] = temp_str.strip()
                elif x[0] == "score_type":
                    gene_object["score_type"] = temp_str.strip()
                elif x[0] == "secondary_id":
                    gene_object["secondary_id"] = temp_str.strip()
                elif x[0] == "symbol":
                    gene_object["symbol"] = temp_str.strip()
                        
        return gene_object
cols = 8
sep = '| '
ellipsis = '...'
line_width = col_width * cols + (cols - 1) * len(sep)
fit_to_cell = lambda a: a.ljust(col_width) if len(
    a) <= col_width else a[:col_width - len(ellipsis)] + ellipsis
hrule = "-" * line_width
summary = "\n%s: %d Alleles"

s = Service("www.flymine.org/query")

Gene = s.model.Gene

q = s.query(Gene).\
      add_columns("name", "symbol", "alleles.*").\
      filter(Gene.symbol == ["zen", "eve", "bib", "h"]).\
      filter(Gene.alleles.symbol == "*hs*").\
      outerjoin(Gene.alleles).\
      order_by("symbol")

for row in q.rows():
    print row

for gene in s.query(s.model.Gene).filter(
        s.model.Gene.symbol == ["zen", "eve", "bib", "h"]).add_columns(
            s.model.Gene.alleles):

    print summary % (gene.symbol, len(gene.alleles))
    print hrule

    for k, line_of_alleles in itertools.groupby(
            sorted(map(lambda a: a.symbol, gene.alleles)), lines_of(cols)):
Beispiel #12
0
col_width = 15
cols = 8
sep = '| '
ellipsis = '...'
line_width = col_width * cols + (cols - 1) * len(sep)
fit_to_cell = lambda a: a.ljust(col_width) if len(a) <= col_width else a[:col_width - len(ellipsis)] + ellipsis
hrule = "-" * line_width
summary = "\n%s: %d Alleles"

s = Service("www.flymine.org/query")

Gene = s.model.Gene

q = s.query(Gene).\
      add_columns("name", "symbol", "alleles.*").\
      filter(Gene.symbol == ["zen", "eve", "bib", "h"]).\
      filter(Gene.alleles.symbol == "*hs*").\
      outerjoin(Gene.alleles).\
      order_by("symbol")

for row in q.rows():
   print row

for gene in s.query(s.model.Gene).filter(s.model.Gene.symbol == ["zen", "eve", "bib", "h"]).add_columns(s.model.Gene.alleles):

    print summary % (gene.symbol, len(gene.alleles))
    print hrule

    for k, line_of_alleles in itertools.groupby(sorted(map(lambda a: a.symbol, gene.alleles)), lines_of(cols)):
        print sep.join(map(fit_to_cell, line_of_alleles))
    
    print "\nAllele Classes:"
Beispiel #13
0
def yeastmine():
    s = Service("https://yeastmine.yeastgenome.org:443/yeastmine/service")
    Gene = s.model.Gene
    q = s.query(Gene).select("*").where("Gene", "LOOKUP", "Rad51")
    gene_object = {}
    for row in q.rows():
        process = row.__str__()
        for x in re.findall(r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})", process):
            print(x)
            
    for iden in gnomics.objects.auxiliary_files.identifier.filter_identifiers(gene.identifiers, ["yeastmine primary id", "yeastmine primary identifier", "yeastmine primary gene id", "yeastmine primary gene identifier"]):
        s = Service("https://yeastmine.yeastgenome.org:443/yeastmine/service")
        Gene = s.model.Gene
        q = s.query(Gene).select("*").where("Gene", "LOOKUP", iden["identifier"])
        gene_object = {}  
        for row in q.rows():
            process = row.__str__()
            for x in re.findall(r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})", process):

                temp_str = x[1]
                if temp_str[0] == "'" and temp_str[-1] == "'":
                    temp_str = temp_str[1:-1]
                    
                if x[0] == "cytoLocation":
                    gene_object["cytogenetic_location"] = temp_str.strip()
                elif x[0] == "description":
                    gene_object["description"] = temp_str.strip()
                elif x[0] == "featAttribute":
                    gene_object["feature_attribute"] = temp_str.strip()
                elif x[0] == "featureType":
                    gene_object["feature_type"] = temp_str.strip()
                elif x[0] == "functionSummary":
                    gene_object["function_summary"] = temp_str.strip()
                elif x[0] == "id":
                    gene_object["id"] = temp_str.strip()
                elif x[0] == "jasparAccession":
                    gene_object["jaspar_accession"] = temp_str.strip()
                elif x[0] == "jasparClass":
                    gene_object["jaspar_class"] = temp_str.strip()
                elif x[0] == "jasparFamily":
                    gene_object["jaspar_family"] = temp_str.strip()
                elif x[0] == "length":
                    gene_object["length"] = temp_str.strip()
                elif x[0] == "phenotypeSummary":
                    gene_object["phenotype_summary"] = temp_str.strip()
                elif x[0] == "primaryIdentifier":
                    gene_object["primary_id"] = temp_str.strip()
                elif x[0] == "qualifier":
                    gene_object["qualifier"] = temp_str.strip()
                elif x[0] == "score":
                    gene_object["score"] = temp_str.strip()
                elif x[0] == "scoreType":
                    gene_object["score_type"] = temp_str.strip()
                elif x[0] == "secondaryIdentifier":
                    gene_object["secondary_id"] = temp_str.strip()
                elif x[0] == "status":
                    gene_object["status"] = temp_str.strip()
                elif x[0] == "symbol":
                    gene_object["symbol"] = temp_str.strip()
                elif x[0] == "name":
                    gene_object["name"] = temp_str.strip()
                elif x[0] == "sgdAlias":
                    gene_object["sgd_alias"] = temp_str.strip()
                        
        return gene_object
Beispiel #14
0
def mousemine(gene):
    for ident in gene.identifiers:
        if ident["identifier_type"].lower() in ["ncbi", "ncbi id", "ncbi gene identifier", "ncbi gene id", "entrez gene id", "entrez id"]:
            s = Service("www.mousemine.org/mousemine")
            Gene = s.model.Gene
            q = s.query(Gene).select("*").where("Gene", "LOOKUP", ident["identifier"])
            gene_object = {}
            for row in q.rows():
                process = row.__str__()
                for x in re.findall(r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})", process):
                    
                    temp_str = x[1]
                    if temp_str[0] == "'" and temp_str[-1] == "'":
                        temp_str = temp_str[1:-1]
                    
                    if x[0] == "briefDescription":
                        if temp_str.strip() == "None":
                            gene_object["brief_description"] = None
                        else:
                            gene_object["brief_description"] = temp_str.strip()
                        
                    elif x[0] == "description":
                        gene_object["description"] = temp_str.strip()
                        
                        for y in re.findall(r"(FUNCTION:[0-9A-Za-z\-\(\) ,.\[]+]|PHENOTYPE:[0-9A-Za-z\-\(\) ,.\[]+])", temp_str):
                            y_split = y.split(":")
                            if y_split[0].strip() == "FUNCTION":
                                gene_object["function"] = y_split[1].strip()
                            elif y_split[0].strip() == "PHENOTYPE":
                                gene_object["phenotype"] = y_split[1].strip()
                    elif x[0] == "id":
                        gene_object["id"] = temp_str.strip()
                    elif x[0] == "length":
                        gene_object["length"] = temp_str.strip()
                    elif x[0] == "mgiType":
                        gene_object["mgi_type"] = temp_str.strip()
                    elif x[0] == "name":
                        gene_object["name"] = temp_str.strip()
                    elif x[0] == "ncbiGeneNumber":
                        gene_object["ncbi_gene_id"] = temp_str.strip()
                    elif x[0] == "primaryIdentifier":
                        gene_object["primary_id"] = temp_str.strip()
                    elif x[0] == "score":
                        if temp_str.strip() == "None":
                            gene_object["score"] = None
                        else:
                            gene_object["score"] = temp_str.strip()
                    elif x[0] == "scoreType":
                        if temp_str.strip() == "None":
                            gene_object["score_type"] = None
                        else:
                            gene_object["score_type"] = temp_str.strip()
                    elif x[0] == "secondaryIdentifier":
                        if temp_str.strip() == "None":
                            gene_object["secondary_id"] = None
                        else:
                            gene_object["secondary_id"] = temp_str.strip()
                    elif x[0] == "specificity":
                        if temp_str.strip() == "None":
                            gene_object["specificity"] = None
                        else:
                            gene_object["specificity"] = temp_str.strip()
                    elif x[0] == "symbol":
                        gene_object["symbol"] = temp_str.strip()
                        
            return gene_object
Beispiel #15
0
def yeastmine():
    s = Service("https://yeastmine.yeastgenome.org:443/yeastmine/service")
    Gene = s.model.Gene
    q = s.query(Gene).select("*").where("Gene", "LOOKUP", "Rad51")
    gene_object = {}
    for row in q.rows():
        process = row.__str__()
        for x in re.findall(
                r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})",
                process):
            print(x)

    for iden in gnomics.objects.auxiliary_files.identifier.filter_identifiers(
            gene.identifiers,
        [
            "yeastmine primary id", "yeastmine primary identifier",
            "yeastmine primary gene id", "yeastmine primary gene identifier"
        ]):
        s = Service("https://yeastmine.yeastgenome.org:443/yeastmine/service")
        Gene = s.model.Gene
        q = s.query(Gene).select("*").where("Gene", "LOOKUP",
                                            iden["identifier"])
        gene_object = {}
        for row in q.rows():
            process = row.__str__()
            for x in re.findall(
                    r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})",
                    process):

                temp_str = x[1]
                if temp_str[0] == "'" and temp_str[-1] == "'":
                    temp_str = temp_str[1:-1]

                if x[0] == "cytoLocation":
                    gene_object["cytogenetic_location"] = temp_str.strip()
                elif x[0] == "description":
                    gene_object["description"] = temp_str.strip()
                elif x[0] == "featAttribute":
                    gene_object["feature_attribute"] = temp_str.strip()
                elif x[0] == "featureType":
                    gene_object["feature_type"] = temp_str.strip()
                elif x[0] == "functionSummary":
                    gene_object["function_summary"] = temp_str.strip()
                elif x[0] == "id":
                    gene_object["id"] = temp_str.strip()
                elif x[0] == "jasparAccession":
                    gene_object["jaspar_accession"] = temp_str.strip()
                elif x[0] == "jasparClass":
                    gene_object["jaspar_class"] = temp_str.strip()
                elif x[0] == "jasparFamily":
                    gene_object["jaspar_family"] = temp_str.strip()
                elif x[0] == "length":
                    gene_object["length"] = temp_str.strip()
                elif x[0] == "phenotypeSummary":
                    gene_object["phenotype_summary"] = temp_str.strip()
                elif x[0] == "primaryIdentifier":
                    gene_object["primary_id"] = temp_str.strip()
                elif x[0] == "qualifier":
                    gene_object["qualifier"] = temp_str.strip()
                elif x[0] == "score":
                    gene_object["score"] = temp_str.strip()
                elif x[0] == "scoreType":
                    gene_object["score_type"] = temp_str.strip()
                elif x[0] == "secondaryIdentifier":
                    gene_object["secondary_id"] = temp_str.strip()
                elif x[0] == "status":
                    gene_object["status"] = temp_str.strip()
                elif x[0] == "symbol":
                    gene_object["symbol"] = temp_str.strip()
                elif x[0] == "name":
                    gene_object["name"] = temp_str.strip()
                elif x[0] == "sgdAlias":
                    gene_object["sgd_alias"] = temp_str.strip()

        return gene_object
Beispiel #16
0
def mousemine(gene):
    for ident in gene.identifiers:
        if ident["identifier_type"].lower() in [
                "ncbi", "ncbi id", "ncbi gene identifier", "ncbi gene id",
                "entrez gene id", "entrez id"
        ]:
            s = Service("www.mousemine.org/mousemine")
            Gene = s.model.Gene
            q = s.query(Gene).select("*").where("Gene", "LOOKUP",
                                                ident["identifier"])
            gene_object = {}
            for row in q.rows():
                process = row.__str__()
                for x in re.findall(
                        r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})",
                        process):

                    temp_str = x[1]
                    if temp_str[0] == "'" and temp_str[-1] == "'":
                        temp_str = temp_str[1:-1]

                    if x[0] == "briefDescription":
                        if temp_str.strip() == "None":
                            gene_object["brief_description"] = None
                        else:
                            gene_object["brief_description"] = temp_str.strip()

                    elif x[0] == "description":
                        gene_object["description"] = temp_str.strip()

                        for y in re.findall(
                                r"(FUNCTION:[0-9A-Za-z\-\(\) ,.\[]+]|PHENOTYPE:[0-9A-Za-z\-\(\) ,.\[]+])",
                                temp_str):
                            y_split = y.split(":")
                            if y_split[0].strip() == "FUNCTION":
                                gene_object["function"] = y_split[1].strip()
                            elif y_split[0].strip() == "PHENOTYPE":
                                gene_object["phenotype"] = y_split[1].strip()
                    elif x[0] == "id":
                        gene_object["id"] = temp_str.strip()
                    elif x[0] == "length":
                        gene_object["length"] = temp_str.strip()
                    elif x[0] == "mgiType":
                        gene_object["mgi_type"] = temp_str.strip()
                    elif x[0] == "name":
                        gene_object["name"] = temp_str.strip()
                    elif x[0] == "ncbiGeneNumber":
                        gene_object["ncbi_gene_id"] = temp_str.strip()
                    elif x[0] == "primaryIdentifier":
                        gene_object["primary_id"] = temp_str.strip()
                    elif x[0] == "score":
                        if temp_str.strip() == "None":
                            gene_object["score"] = None
                        else:
                            gene_object["score"] = temp_str.strip()
                    elif x[0] == "scoreType":
                        if temp_str.strip() == "None":
                            gene_object["score_type"] = None
                        else:
                            gene_object["score_type"] = temp_str.strip()
                    elif x[0] == "secondaryIdentifier":
                        if temp_str.strip() == "None":
                            gene_object["secondary_id"] = None
                        else:
                            gene_object["secondary_id"] = temp_str.strip()
                    elif x[0] == "specificity":
                        if temp_str.strip() == "None":
                            gene_object["specificity"] = None
                        else:
                            gene_object["specificity"] = temp_str.strip()
                    elif x[0] == "symbol":
                        gene_object["symbol"] = temp_str.strip()

            return gene_object