Annot = Annotation.Annotation()
                Annot.annotationID = ann[0]
                Annot.Content = ann[1]
                Annot.Start = ann[2]
                Annot.End = ann[3]
                Annot.AnnotationCID = ann[4]
                Annot.AnnotationDesc =ann[5]
                Annot.AgentName = ann[6]
                Annot.AgentType = ann[7]
                Annot.AnnotationURL = ann[8]
                cell_annotations.append(Annot)
        cell.Annotations = cell_annotations
        cells.append(cell)
    return cells
if __name__=="__main__":
    queryclass = QueryDBCalss("localhost","root","","ddi_data", )
    queryclass.CreateAdditionalDDITables()
    cursor = queryclass.db.cursor()
    #Get tables
    sql = """SELECT idArticle,Title,SpecId,idTable,TableOrder,TableCaption,Section FROM ddi_data.article inner join
     arttable on idArticle=Article_idArticle where Section='34073-7'"""
    #Get cells and annotations that contain potential DDIs
    #sql = """select annotation.Content,AnnotationDescription,Table_idTable,RowN,ColumnN,TableOrder,idArticle,Title,SpecId,
    #AnnotationID from annotation inner join cell on cell.idCell=annotation.Cell_idCell inner join arttable on
    #arttable.idTable=cell.Table_idTable inner join article on article.idArticle = arttable.Article_idArticle
    #where Section='34073-7' and AnnotationDescription  IN ('Pharmacologic Substance (phsu)','Biologically Active Substance (bacs)',
    #'Organic Chemical (orch)','Hazardous or Poisonous Substance (hops)','Carbohydrate (carb)','Element, Ion, or Isotope (elii)',
    #'Nucleic Acid, Nucleoside, or Nucleotide (nnon)','Indicator, Reagent, or Diagnostic Aid (irda)',
    #'Biomedical or Dental Material (bodm)', 'Inorganic Chemical (inch)','Hormone (horm)')
    #"""
    cursor.execute(sql)
示例#2
0
                Annot.End = ann[3]
                Annot.AnnotationCID = ann[4]
                Annot.AnnotationDesc = ann[5]
                Annot.AgentName = ann[6]
                Annot.AgentType = ann[7]
                Annot.AnnotationURL = ann[8]
                cell_annotations.append(Annot)
        cell.Annotations = cell_annotations
        cells.append(cell)
    return cells


if __name__ == "__main__":
    queryclass = QueryDBCalss(
        "localhost",
        "root",
        "",
        "table_db_amia",
    )
    queryclass.CreateAdditionalDDITables()
    cursor = queryclass.db.cursor()
    #Get tables
    sql = """SELECT idArticle,Title,SpecId,idTable,TableOrder,TableCaption,Section FROM table_db_amia.article inner join
     arttable on idArticle=Article_idArticle where Section='34073-7'"""
    #Get cells and annotations that contain potential DDIs
    #sql = """select annotation.Content,AnnotationDescription,Table_idTable,RowN,ColumnN,TableOrder,idArticle,Title,SpecId,
    #AnnotationID from annotation inner join cell on cell.idCell=annotation.Cell_idCell inner join arttable on
    #arttable.idTable=cell.Table_idTable inner join article on article.idArticle = arttable.Article_idArticle
    #where Section='34073-7' and AnnotationDescription  IN ('Pharmacologic Substance (phsu)','Biologically Active Substance (bacs)',
    #'Organic Chemical (orch)','Hazardous or Poisonous Substance (hops)','Carbohydrate (carb)','Element, Ion, or Isotope (elii)',
    #'Nucleic Acid, Nucleoside, or Nucleotide (nnon)','Indicator, Reagent, or Diagnostic Aid (irda)',
    #'Biomedical or Dental Material (bodm)', 'Inorganic Chemical (inch)','Hormone (horm)')
'''
Created on 2 Mar 2016

@author: mbaxkhm4

Created at the University of Manchester, School of Computer Science
Licence GNU/GPL 3.0
'''
from QueryDBClass import QueryDBCalss
from  Data.Table import Table
import re
if __name__=="__main__":
    queryclass = QueryDBCalss("localhost","root","","table_db" )
    queryclass.DeleteAttribute("BMI")
    queryclass.CreateAdditionalTables()
    results = queryclass.getArticles()
    articleIds = []
    for row in results:
        articleIds.append(row[0])
    del results
    #articleIds = [1501]
    for id in articleIds:
        results = queryclass.getArticleTables(id)
        tables = []
        for t in results:
            table = Table()
            table.tableId = t[0]
            table.tableOrder = t[1]
            table.tableCaption = t[2]
            table.tableFooter = t[3]
            table.StructureType = t[4]
示例#4
0
'''
Created on 18 Oct 2016

@author: mbaxkhm4

Created at the University of Manchester, School of Computer Science
Licence GNU/GPL 3.0
'''
from QueryDBClass import QueryDBCalss
from  Data.Table import Table
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
if __name__=="__main__":
    queryclass = QueryDBCalss("localhost","root","","table_db_amia", )
    queryclass.CreateAdditionalDDITables()
    cursor = queryclass.db.cursor()
    d = {}
    with open("Categories.txt") as f:
        for line in f:
            spl = line.split('\t')
            print spl[0]
            d[spl[0].lower()] = spl[1].replace('\n','').lower()
    print d
    sql = """select Content,Table_idTable,RowN,ColumnN,TableOrder,idArticle,Title,SpecId,CellRole_idCellRole from cell inner join arttable on arttable.idTable=cell.Table_idTable inner join article on 
    article.idArticle = arttable.Article_idArticle inner join cellroles on cellroles.Cell_idCell=cell.idCell where Section='34073-7'"""
    cursor.execute(sql)
    results = cursor.fetchall()
    columnOfDrugs = -1
    isfirst = False
    for res in results:
示例#5
0
# -*- coding: utf-8 -*-
'''
Created on 26 Feb 2016

@author: mbaxkhm4

Created at the University of Manchester, School of Computer Science
Licence GNU/GPL 3.0
'''
from QueryDBClass import QueryDBCalss
from Data.Table import Table
import re
if __name__ == "__main__":
    queryclass = QueryDBCalss("localhost", "root", "", "table_db")
    queryclass.ClearCreatedTables()
    queryclass.CreateAdditionalTables()
    results = queryclass.getArticles()
    articleIds = []
    PMCs = []
    for row in results:
        articleIds.append(row[0])
        PMCs.append(row[1])
    del results
    l = 0
    #articleIds = [5531]
    for id in articleIds:
        results = queryclass.getArticleTablesWithPragmatic(
            id, "BaselineCharacteristic")
        tables = []
        for t in results:
            table = Table()
#!/usr/bin/env python
# -*- coding: utf-8 -*- 
'''
Created on Apr 14, 2016

@author: Nikola

Created at the University of Manchester, School of Computer Science
Licence GNU/GPL 3.0
'''
from QueryDBClass import QueryDBCalss
from  Data.Table import Table
import re
if __name__=="__main__":
    queryclass = QueryDBCalss("localhost","root","","table_db" )
    results = queryclass.getDataForDevDataset()
    target = open("developmentCellDataset.csv", 'w')                                                                                          
    target.write("ArticleId,PMCid,TableName,SpecPragmatics,CellContent,Header,Stub,SuperRow,rowN,columnN,function,class\n")
    for res in results:
        idArticle = res[0]
        PMCid = res[1]
        idTable = res[2]
        TableOrder = res[3]
        SpecPragmatic = res[4]
        idCell = res[5]
        CellType = res[6]
        RowN = res[7]
        ColumnN =res[8]
        Content = res[9]
        Header = res[10]
        Stub = res[11]
示例#7
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 7 Apr 2016

@author: mbaxknm4

Created at the University of Manchester, School of Computer Science
Licence GNU/GPL 3.0
'''
from QueryDBClass import QueryDBCalss
from Data.Table import Table
from collections import Counter
import re
if __name__ == "__main__":
    queryclass = QueryDBCalss("localhost", "root", "", "table_db")
    queryclass.ClearCreatedTables()
    queryclass.CreateAdditionalTables()
    results = queryclass.getArticles()
    articleIds = []
    for row in results:
        articleIds.append(row[0])
    del results
    #articleIds = [2418]
    for id in articleIds:
        results = queryclass.getArticleTablesWithPragmatic(id, "AdverseEvent")
        tables = []
        for t in results:
            table = Table()
            table.tableId = t[0]
            table.tableOrder = t[1]
示例#8
0
'''
Created on 22 Aug 2016

@author: mbaxkhm4

Created at the University of Manchester, School of Computer Science
Licence GNU/GPL 3.0
'''
from QueryDBClass import QueryDBCalss
from  Data.Table import Table
from AnalyzePattern import GetMean,GetRange
import re
if __name__=="__main__":
    queryclass = QueryDBCalss("localhost","root","","table_db", )
    queryclass.DeleteAttribute("Age")
    queryclass.CreateAdditionalTables()
    results = queryclass.getCellsWithMetaMapAnnotation("BaselineCharacteristic","orga")
    lastCellID = -1
    for res in results:
        CellID = res[0]
        if(CellID==lastCellID):
            continue
        TableID = res[3]
        RowN = res[4]
        ColumtnN = res[5]
        Content = res[9]
        Header  = res [10]
        Stub = res[11]
        SuperRow = res[12]
        AnnotationContent = res[14]
        AnnotationDesc = res[19]
'''
Created on 11 Apr 2016

@author: mbaxkhm4

Created at the University of Manchester, School of Computer Science
Licence GNU/GPL 3.0
'''
from QueryDBClass import QueryDBCalss
from  Data.Table import Table
import re
if __name__=="__main__":
    queryclass = QueryDBCalss("localhost","root","","table_db" )
    queryclass.DeleteAttribute("BMI")
    queryclass.CreateAdditionalTables()
    results = queryclass.getArticles()
    articleIds = []
    for row in results:
        articleIds.append(row[0])
    del results
    for id in articleIds:
        results = queryclass.getArticleTables(id)
        tables = []
        for t in results:
            table = Table()
            table.tableId = t[0]
            table.tableOrder = t[1]
            table.tableCaption = t[2]
            table.tableFooter = t[3]
            table.StructureType = t[4]
            table.PrgamaticType = t[5]
from QueryDBClass import QueryDBCalss

queryclass = QueryDBCalss(
    "localhost",
    "root",
    "",
    "table_db",
)
cursor = queryclass.db.cursor()
#Get tables
sql = """SELECT Content FROM table_db.article inner join arttable on arttable.Article_idArticle=article.idArticle inner
join cell on arttable.idTable=cell.Table_idTable where Title like '%asthma%' or Title like '%Asthma%' or Abstract like
'%asthma%' or  Abstract like '%Asthma%';"""
cursor.execute(sql)
results = cursor.fetchall()
file = open("content_asthma.txt", "w")
for res in results:
    file.write(res[0].encode('utf-8') + '\n')
file.close()

print "Done Asthma"

sql = """SELECT Content FROM table_db.article inner join arttable on arttable.Article_idArticle=article.idArticle inner
join cell on arttable.idTable=cell.Table_idTable where Title like '%COPD%' or Title like '%copd%' or Abstract like
'%COPD%' or  Abstract like '%copd%' or Title like '%chronic obstructive pulmonary disease%' or Title like '%Chronic obstructive pulmonary disease%' or
Abstract like '%Chronic obstructive pulmonary disease%' or Abstract like "%chronic obstructive pulmonary disease%";"""
cursor.execute(sql)
results = cursor.fetchall()
file = open("content_copd.txt", "w")
for res in results:
    file.write(res[0].encode('utf-8') + '\n')
#!/usr/bin/env python
# -*- coding: utf-8 -*- 
'''
Created on 2 Mar 2016

@author: mbaxkhm4

Created at the University of Manchester, School of Computer Science
Licence GNU/GPL 3.0
'''
from QueryDBClass import QueryDBCalss
from  Data.Table import Table
from AnalyzePattern import GetMean,GetRange
import re
if __name__=="__main__":
    queryclass = QueryDBCalss("localhost","root","","table_db", )
    queryclass.DeleteAttribute("Age")
    queryclass.CreateAdditionalTables()
    results = queryclass.getArticles()
    articleIds = []
    PMCs = []
    for row in results:
        articleIds.append(row[0])
        PMCs.append(row[1])
    del results
    #articleIds = [1252]
    l = 0
    for id in articleIds:
        results = queryclass.getArticleTablesWithPragmatic(id,"BaselineCharacteristic")
        tables = []
        for t in results:
'''
Created on 2 Mar 2016

@author: mbaxkhm4

Created at the University of Manchester, School of Computer Science
Licence GNU/GPL 3.0
'''
from QueryDBClass import QueryDBCalss
from  Data.Table import Table
import re
if __name__=="__main__":
    queryclass = QueryDBCalss("localhost","root","","table_db" )
    queryclass.DeleteAttribute("Age")
    queryclass.CreateAdditionalTables()
    results = queryclass.getArticles()
    articleIds = []
    for row in results:
        articleIds.append(row[0])
    del results
    for id in articleIds:
        results = queryclass.getArticleTables(id)
        tables = []
        for t in results:
            table = Table()
            table.tableId = t[0]
            table.tableOrder = t[1]
            table.tableCaption = t[2]
            table.tableFooter = t[3]
            table.StructureType = t[4]
            table.PrgamaticType = t[5]
示例#13
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on Apr 14, 2016

@author: Nikola

Created at the University of Manchester, School of Computer Science
Licence GNU/GPL 3.0
'''
from QueryDBClass import QueryDBCalss
from Data.Table import Table
import re
if __name__ == "__main__":
    queryclass = QueryDBCalss("localhost", "root", "", "table_db")
    results = queryclass.getDataForDevDataset()
    target = open("developmentCellDataset.csv", 'w')
    target.write(
        "ArticleId,PMCid,TableName,SpecPragmatics,CellContent,Header,Stub,SuperRow,rowN,columnN,function,class\n"
    )
    for res in results:
        idArticle = res[0]
        PMCid = res[1]
        idTable = res[2]
        TableOrder = res[3]
        SpecPragmatic = res[4]
        idCell = res[5]
        CellType = res[6]
        RowN = res[7]
        ColumnN = res[8]
        Content = res[9]
#!/usr/bin/env python
# -*- coding: utf-8 -*- 
'''
Created on 7 Apr 2016

@author: mbaxknm4

Created at the University of Manchester, School of Computer Science
Licence GNU/GPL 3.0
'''
from QueryDBClass import QueryDBCalss
from  Data.Table import Table
from collections import Counter
import re
if __name__=="__main__":
    queryclass = QueryDBCalss("localhost","root","","table_db" )
    queryclass.ClearCreatedTables()
    queryclass.CreateAdditionalTables()
    results = queryclass.getArticles()
    articleIds = []
    for row in results:
        articleIds.append(row[0])
    del results
    articleIds = [1334]
    for id in articleIds:
        results = queryclass.getArticleTablesWithPragmatic(id,"AdverseEvent")
        tables = []
        for t in results:
            table = Table()
            table.tableId = t[0]
            table.tableOrder = t[1]
示例#15
0
'''
Created on 11 Apr 2016

@author: mbaxkhm4

Created at the University of Manchester, School of Computer Science
Licence GNU/GPL 3.0
'''
from QueryDBClass import QueryDBCalss
from Data.Table import Table
import re
if __name__ == "__main__":
    queryclass = QueryDBCalss("localhost", "root", "", "table_db")
    queryclass.DeleteAttribute("BMI")
    queryclass.CreateAdditionalTables()
    results = queryclass.getArticles()
    articleIds = []
    for row in results:
        articleIds.append(row[0])
    del results
    for id in articleIds:
        results = queryclass.getArticleTables(id)
        tables = []
        for t in results:
            table = Table()
            table.tableId = t[0]
            table.tableOrder = t[1]
            table.tableCaption = t[2]
            table.tableFooter = t[3]
            table.StructureType = t[4]
            table.PrgamaticType = t[5]
示例#16
0
'''
Created on 2 Mar 2016

@author: mbaxkhm4

Created at the University of Manchester, School of Computer Science
Licence GNU/GPL 3.0
'''
from QueryDBClass import QueryDBCalss
from Data.Table import Table
import re
if __name__ == "__main__":
    queryclass = QueryDBCalss("localhost", "root", "", "table_db")
    queryclass.DeleteAttribute("BMI")
    queryclass.CreateAdditionalTables()
    results = queryclass.getArticles()
    articleIds = []
    for row in results:
        articleIds.append(row[0])
    del results
    #articleIds = [1501]
    for id in articleIds:
        results = queryclass.getArticleTables(id)
        tables = []
        for t in results:
            table = Table()
            table.tableId = t[0]
            table.tableOrder = t[1]
            table.tableCaption = t[2]
            table.tableFooter = t[3]
            table.StructureType = t[4]
示例#17
0
文件: getAge.py 项目: ss756/TabInOut
'''
Created on 2 Mar 2016

@author: mbaxkhm4

Created at the University of Manchester, School of Computer Science
Licence GNU/GPL 3.0
'''
from QueryDBClass import QueryDBCalss
from Data.Table import Table
from AnalyzePattern import GetMean, GetRange
import re
if __name__ == "__main__":
    queryclass = QueryDBCalss(
        "localhost",
        "root",
        "",
        "table_db",
    )
    queryclass.DeleteAttribute("Age")
    queryclass.CreateAdditionalTables()
    results = queryclass.getArticles()
    articleIds = []
    PMCs = []
    for row in results:
        articleIds.append(row[0])
        PMCs.append(row[1])
    del results
    #articleIds = [1252]
    l = 0
    for id in articleIds:
        results = queryclass.getArticleTablesWithPragmatic(
# -*- coding: utf-8 -*-
'''
Created on 26 Feb 2016

@author: mbaxkhm4

Created at the University of Manchester, School of Computer Science
Licence GNU/GPL 3.0
'''
from QueryDBClass import QueryDBCalss
from  Data.Table import Table
import re
if __name__=="__main__":
    queryclass = QueryDBCalss("localhost","root","","table_db" )
    queryclass.ClearCreatedTables()
    queryclass.CreateAdditionalTables()
    results = queryclass.getArticles()
    articleIds = []
    PMCs = []
    for row in results:
        articleIds.append(row[0])
        PMCs.append(row[1])
    del results
    l=0
    #articleIds = [5531]
    for id in articleIds:
        results = queryclass.getArticleTablesWithPragmatic(id,"BaselineCharacteristic")
        tables = []
        for t in results:
            table = Table()
            table.tableId = t[0]