# Path: plugin.py
# class Plugin:
# class PluginManager:
# class Documents:
#     def __init__(self):
#     def user(self):
#     def process(self, request):
#     def unload(self):
#     def __init__(self):
#     def load_plugin(self, name, reload=False):
#     def get_plugins(self):
#     def send_request(self, plugin, request):
#     def __init__(self, plugin: Plugin):
#     def set_document_type(self, name: str):
#     def set_document_table(self, table):
#     def get(self, pid):
#     def list(self, owner):
#     def create(self, pdoc: PluginDocument):
#     def update(pdoc: PluginDocument):
#     def delete(self, pdoc: PluginDocument):
# 
# Path: database.py
# def get_session():
# def teardown_session(exception):
# 
# Path: database.py
# def get_session():
# def teardown_session(exception):
# 
# Path: plugins/dbupload/dbprofile.py
# class Gene(TableBase):
#     __tablename__ = 'allgeneinfo_all'
#     tax_id = Column(String(10))
#     gene_id = Column(String(10), primary_key=True)
#     Symbol = Column(String(64))
#     LocusTag = Column(Text)
#     Synonyms = Column(Text)
#     dbXrefs = Column(Text)
#     chromosome = Column(Text)
#     map_location = Column(Text)
#     description = Column(Text)
#     type_of_gene = Column(Text)
#     Symbol_from_nomenclature_authority = Column(Text)
#     Full_name_from_nomenclature_authority = Column(Text)
#     Nomenclature_status = Column(Text)
#     Other_designations = Column(Text)
#     Modification_date = Column(Date)


from time import time
from plugin import Plugin, PluginDocument
from database import TableBase, Column, Text, Integer, Boolean
from database import engine, session
from .dbupload.dbprofile import Gene
        doc = self.documents.get(id)
        if not (doc and (doc.owner == self.user.id or doc.public)):
            raise ValueError('Document %d does not exists.' % id)
        praises = eval(doc.praises)
        praises.discard(self.user.id)
        if modify:
            praises.add(self.user.id)
        doc.praises = repr(praises)
        self.documents.update(doc)
        return {}

    def get_project_data(self, **kwargs):
        events = []
        for i in self.documents.list(self.user.id):
            events.append(dict(project_id=i.id, user_id=i.owner, time=i.created, img_src=i.description, public=i.public,
                project_name=i.title, last_update_time=i.last_modified, praise=self.user.id in eval(i.praises),
                comment=eval(i.comments)))
        return dict(project=events)

    def match_node(self, s, **kwargs):

        suggest = {'nodes':[]}

        for res in session.query(Gene).filter(Gene.gene_id == s):
            print("There there")
            temp = {'name': res.Symbol, 'gene_id': res.gene_id, 'info': res.description,
                    'tax_id': res.tax_id, 'equal': res.Symbol == s}
            suggest['nodes'].append(temp)
            return suggest


# Path: plugin.py
# class Plugin:
# class PluginManager:
# class Documents:
#     def __init__(self):
#     def user(self):
#     def process(self, request):
#     def unload(self):
#     def __init__(self):
#     def load_plugin(self, name, reload=False):
#     def get_plugins(self):
#     def send_request(self, plugin, request):
#     def __init__(self, plugin: Plugin):
#     def set_document_type(self, name: str):
#     def set_document_table(self, table):
#     def get(self, pid):
#     def list(self, owner):
#     def create(self, pdoc: PluginDocument):
#     def update(pdoc: PluginDocument):
#     def delete(self, pdoc: PluginDocument):
# 
# Path: database.py
# def get_session():
# def teardown_session(exception):
# 
# Path: database.py
# def get_session():
# def teardown_session(exception):
# 
# Path: plugins/dbupload/dbprofile.py
# class Gene(TableBase):
#     __tablename__ = 'allgeneinfo_all'
#     tax_id = Column(String(10))
#     gene_id = Column(String(10), primary_key=True)
#     Symbol = Column(String(64))
#     LocusTag = Column(Text)
#     Synonyms = Column(Text)
#     dbXrefs = Column(Text)
#     chromosome = Column(Text)
#     map_location = Column(Text)
#     description = Column(Text)
#     type_of_gene = Column(Text)
#     Symbol_from_nomenclature_authority = Column(Text)
#     Full_name_from_nomenclature_authority = Column(Text)
#     Nomenclature_status = Column(Text)
#     Other_designations = Column(Text)
#     Modification_date = Column(Date)


# Path: plugins/pano.py
from time import time
from plugin import Plugin, PluginDocument
from database import TableBase, Column, Text, Integer, Boolean
from database import engine, session
from .dbupload.dbprofile import Gene

        doc = self.documents.get(id)
        if not (doc and (doc.owner == self.user.id or doc.public)):
            raise ValueError('Document %d does not exists.' % id)
        praises = eval(doc.praises)
        praises.discard(self.user.id)
        if modify:
            praises.add(self.user.id)
        doc.praises = repr(praises)
        self.documents.update(doc)
        return {}

    def get_project_data(self, **kwargs):
        events = []
        for i in self.documents.list(self.user.id):
            events.append(dict(project_id=i.id, user_id=i.owner, time=i.created, img_src=i.description, public=i.public,
                project_name=i.title, last_update_time=i.last_modified, praise=self.user.id in eval(i.praises),
                comment=eval(i.comments)))
        return dict(project=events)

    def match_node(self, s, **kwargs):

        suggest = {'nodes':[]}

        for res in session.query(Gene).filter(Gene.gene_id == s):
            print("There there")
            temp = {'name': res.Symbol, 'gene_id': res.gene_id, 'info': res.description,
                    'tax_id': res.tax_id, 'equal': res.Symbol == s}
            suggest['nodes'].append(temp)
            return suggest


        for res in session.query(Gene).filter(Gene.Symbol.like(s+'%')).limit(100):