# Path: database.py
# def get_session():
# def teardown_session(exception):
# 
# Path: plugin.py
# class Plugin:
#     def __init__(self):
#         self.documents = Documents(self)
#         try: self.name
#         except: self.name = self.__class__.__name__.lower()
#         try: self.description
#         except: self.description = 'This plugin has no description.'
#         if self.__class__ is Plugin:
#             raise NotImplementedError
# 
#     @property
#     def user(self):
#         return app.current_user
# 
#     def process(self, request):
#         pass
# 
#     def unload(self):
#         pass
# 
# Path: plugins/dbupload/dbprofile.py
# class biosys_single(TableBase):
#     __tablename__ = 'biosys_562'
#     id = Column(Integer, primary_key=True, autoincrement=True)
#     tax_id = Column(String(10))
#     gene_id = Column(String(10))
#     bsid = Column(Integer)
#     Symbol = Column(String(64))
# 
# 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 queue import Queue, PriorityQueue
from datetime import *
from database import session
from plugin import Plugin
from .dbupload.dbprofile import biosys_single, Gene
        return
    p_queue.put(State(dis[src], 0, src, [src]))
    while not p_queue.empty():
        s = p_queue.get()
        if s.cur == dst:
            yield s.prepath
            cnt += 1
            if cnt == pathnum:
                break
        for v in Graph[s.cur]:
            if v not in s.prepath:
                p_queue.put(State(s.g + 1 + dis[v], s.g + 1, v, s.prepath + [v]))

        if (datetime.now() - time_monitor).seconds > 5:
            yield "Timeout"
            return


def path_finder(s, t, k, maxlen):  # s:starting point, t:terminal point, k:number of paths required
    calcu_dis(t, node_count, maxlen)
    path_list = []  # contain the found paths
    node_pool = []
    requested = {}
    for p in a_star(s, t, k):
        if p == "None" or p == "Timeout":
            break
        else:
            for gene_id in p:
                if gene_id not in requested:
                    requested[gene_id] = True

# Path: database.py
# def get_session():
# def teardown_session(exception):
# 
# Path: plugin.py
# class Plugin:
#     def __init__(self):
#         self.documents = Documents(self)
#         try: self.name
#         except: self.name = self.__class__.__name__.lower()
#         try: self.description
#         except: self.description = 'This plugin has no description.'
#         if self.__class__ is Plugin:
#             raise NotImplementedError
# 
#     @property
#     def user(self):
#         return app.current_user
# 
#     def process(self, request):
#         pass
# 
#     def unload(self):
#         pass
# 
# Path: plugins/dbupload/dbprofile.py
# class biosys_single(TableBase):
#     __tablename__ = 'biosys_562'
#     id = Column(Integer, primary_key=True, autoincrement=True)
#     tax_id = Column(String(10))
#     gene_id = Column(String(10))
#     bsid = Column(Integer)
#     Symbol = Column(String(64))
# 
# 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/path_finder.py
from queue import Queue, PriorityQueue
from datetime import *
from database import session
from plugin import Plugin
from .dbupload.dbprofile import biosys_single, Gene

        return
    p_queue.put(State(dis[src], 0, src, [src]))
    while not p_queue.empty():
        s = p_queue.get()
        if s.cur == dst:
            yield s.prepath
            cnt += 1
            if cnt == pathnum:
                break
        for v in Graph[s.cur]:
            if v not in s.prepath:
                p_queue.put(State(s.g + 1 + dis[v], s.g + 1, v, s.prepath + [v]))

        if (datetime.now() - time_monitor).seconds > 5:
            yield "Timeout"
            return


def path_finder(s, t, k, maxlen):  # s:starting point, t:terminal point, k:number of paths required
    calcu_dis(t, node_count, maxlen)
    path_list = []  # contain the found paths
    node_pool = []
    requested = {}
    for p in a_star(s, t, k):
        if p == "None" or p == "Timeout":
            break
        else:
            for gene_id in p:
                if gene_id not in requested:
                    requested[gene_id] = True

                    node = session.query(Gene).get(gene_id)