def setEquipo(self):

        participarCopa = "null"

        if self.copa is not None:

            participarCopa = self.copa

        if self.grupo is None:

            self.grupo = "Null"

            cursor = BD().run(
                "insert into Equipo (idEquipo, Copa_idCopa, Liga_idLiga, Nombre, Grupo) values (null, "
                + str(participarCopa) + ", '" + str(self.liga) + "', '" +
                self.nombre + "', " + str(self.grupo) + ");")

        elif self.grupo is not None:

            cursor = BD().run(
                "insert into Equipo (idEquipo, Copa_idCopa, Liga_idLiga, Nombre, Grupo) values (null, "
                + str(participarCopa) + ", '" + str(self.liga) + "', '" +
                self.nombre + "', '" + str(self.grupo) + "');")

        self.id = cursor.lastrowid
예제 #2
0
    def setPartido(self):

        if self.Copa is None and self.Liga is None:

            esLiga = "null"
            esCopa = "null"

            self.Liga = esLiga
            self.Copa = esCopa

        elif self.Copa is None:

            esCopa = "null"

            self.Copa = esCopa

        elif self.Liga is None:

            esLiga = "null"

            self.Liga = esLiga

        if self.Instancia is None:

            self.Instancia = "null"

        if self.Fecha is None:

            self.Fecha = "null"

        if self.GolesEquipo1 != "Null" and self.GolesEquipo2 != "Null":

            self.Horario = "Finalizado"

        if self.Instancia == "Null":

            cursor = BD().run(
                "insert into Partido (idPartidos, idEquipo1, idEquipo2, GolesEquipo1, GolesEquipo2, Liga_idLiga, Copa_idCopa, Instancia, NroFecha, Dia, Horario) values (null, '"
                + str(self.Equipo1) + "','" + str(self.Equipo2) + "', " +
                (self.GolesEquipo1) + "," + (self.GolesEquipo2) + "," +
                str(self.Liga) + ", " + str(self.Copa) + "," +
                str(self.Instancia) + ", " + str(self.Fecha) + ", '" +
                str(self.Dia) + "', '" + str(self.Horario) + "');")

            self.id = cursor.lastrowid

        else:

            cursor = BD().run(
                "insert into Partido (idPartidos, idEquipo1, idEquipo2, GolesEquipo1, GolesEquipo2, Liga_idLiga, Copa_idCopa, Instancia, NroFecha, Dia, Horario) values (null, '"
                + str(self.Equipo1) + "','" + str(self.Equipo2) + "', " +
                (self.GolesEquipo1) + "," + (self.GolesEquipo2) + "," +
                str(self.Liga) + ", " + str(self.Copa) + ",'" +
                str(self.Instancia) + "', " + str(self.Fecha) + ", '" +
                str(self.Dia) + "', '" + str(self.Horario) + "');")

            self.id = cursor.lastrowid
예제 #3
0
    def updatePartido(self):

        if self.Copa is None and self.Liga is None:

            esLiga = "null"
            esCopa = "null"

            self.Liga = esLiga
            self.Copa = esCopa

        elif self.Copa is None:

            esCopa = "null"

            self.Copa = esCopa

        elif self.Liga is None:

            esLiga = "null"

            self.Liga = esLiga

        if self.Instancia is None:

            self.Instancia = "null"

        if self.GolesEquipo1 != "Null" and self.GolesEquipo2 != "Null":

            self.Horario = "Finalizado"

        if self.Instancia == "Null":

            BD().run("update Partido set idEquipo1 = '" + str(self.Equipo1) +
                     "',idEquipo2 = '" + str(self.Equipo2) +
                     "', GolesEquipo1 = " + self.GolesEquipo1 +
                     ",GolesEquipo2 = " + self.GolesEquipo2 +
                     ", Copa_idCopa = " + str(self.Copa) + ", Liga_idLiga = " +
                     str(self.Liga) + ", NroFecha = " + str(self.Fecha) +
                     ", Dia = '" + str(self.Dia) + "', Horario= '" +
                     str(self.Horario) + "', Instancia = " +
                     str(self.Instancia) + " where idPartidos = '" +
                     str(self.id) + "';")
        else:

            BD().run("update Partido set idEquipo1 = '" + str(self.Equipo1) +
                     "',idEquipo2 = '" + str(self.Equipo2) +
                     "', GolesEquipo1 = " + self.GolesEquipo1 +
                     ",GolesEquipo2 = " + self.GolesEquipo2 +
                     ", Copa_idCopa = " + str(self.Copa) + ", Liga_idLiga = " +
                     str(self.Liga) + ", NroFecha = " + str(self.Fecha) +
                     ", Dia = '" + str(self.Dia) + "', Horario= '" +
                     str(self.Horario) + "', Instancia = '" +
                     str(self.Instancia) + "' where idPartidos = '" +
                     str(self.id) + "';")
    def setEquipo(self):

        cursor = BD().run(
            "insert into Equipo (idEquipo, Nombre, Liga_idLiga, Fecha_Creacion) values (null, '"
            + self.nombre + "', '" + str(self.idLigaFK) + "','" +
            str(self.fecha_creacion) + "');")
        self.id = cursor.lastrowid
예제 #5
0
 def mcmc(self):
     result = [0 for i in range(len(self.__space))]
     random_ind = np.random.randint(len(self.__space))
     random_state = self.__space[random_ind]
     for iter in range(self.__m):
         result[random_ind] += 1
         neighbours = self.__get_neighbours(random_ind)
         chosen = neighbours[np.random.randint(len(neighbours))]
         c_E = self.__E(chosen)
         r_E = self.__E(random_state)
         dE = c_E - r_E
         p = self.__get_p_accept_metropolis(
             dE, 1 / len(neighbours),
             1 / len(self.__get_neighbours(chosen)))
         coin = np.random.binomial(1, p)
         random_state = chosen if coin else random_state
         conf = self.__space
         if type(chosen) is not tuple:
             chosen_ind = 0
         else:
             chosen_ind = conf[1:].index(chosen)
         random_ind = chosen_ind if coin else random_ind
     best_configuration = self.__space[np.argmax(np.asarray(result))]
     bd = BD(10, self.__kt, self.__dt, best_configuration, 2,
             self.__protein_dict, self.__protein_vec, self.__df)
     return result, best_configuration, bd.BD_algorithm()
    def setUsuario(self):

        cursor = BD().run(
            "insert into Usuario (idUsuario, Nombre, Contraseña) values (null, '"
            + self.nombre + "', '" + self.contraseña + "');")

        self.id = cursor.lastrowid
예제 #7
0
def main():
    """
    The main function that runs the program.
    At first the main gui window is opened, letting the user to choose the program he wants
    to run (BD or MCMC). Then, according to the user's choice, the matching window is opened
    and the user can enter his arguments.
    Finally, an histogram plot is shown, according to the chosen program's output
    """
    global iterations
    algo = MAINgui()
    chosen_proteins = []
    file_path = ""
    best_config = ""
    if algo == MCMC:
        run = MCMCgui
    else:
        run = BDgui
    while not isValid:
        chosen_proteins = []
        file_path = run(chosen_proteins)
    if algo == MCMC:
        vec = pd.read_csv(file_path)
        mcmc_obj = mcmc.MCMC(len(chosen_proteins), kT, 0, chosen_proteins, dT,
                             list(vec))
        results = mcmc_obj.mcmc()
        best_config, hist_arr = results[1], results[2][1]
        iterations = 10
    else:
        matrix, idxs = read_excel(chosen_proteins)
        bd_obj = bd.BD(iterations, kT, dT, (0, 0), len(chosen_proteins), idxs,
                       chosen_proteins, matrix)
        hist_arr = bd_obj.BD_algorithm()[1]
    histogram(hist_arr, best_config)
예제 #8
0
    def updateProde(self):

        BD().run("update Prode set Usuario_idUsuario = '" + str(self.usuario) +
                 "', GolesEquipo1 = '" + str(self.golesEquipo1) +
                 "', GolesEquipo2 = '" + str(self.golesEquipo2) +
                 "', Partido_idPartidos = '" + str(self.partido) +
                 "' where idProde = '" + str(self.id) + "' ;")
예제 #9
0
    def setProde(self):

        cursor = BD().run(
            "insert into Prode (idProde, Usuario_idUsuario, GolesEquipo1, GolesEquipo2, Partido_idPartidos) values (null,'"
            + str(self.usuario) + "', '" + str(self.golesEquipo1) + "', '" +
            str(self.golesEquipo2) + "', '" + str(self.partido) + "' );")

        self.id = cursor.lastrowid
    def deleteUsuario(self):

        # contadorProde = BD().run("select count(*) from Prode where Usuario_idUsuario = '"+str(self.id)+"';")
        #
        # cont1 = None

        BD().run("delete from Usuario where idUsuario = '" + str(self.id) +
                 "';")
    def getUsuarioPorNombre(username):

        u = BD().run("select * from Usuario where Nombre = '" + username +
                     "';")
        usuario = u.fetchall()
        iduser = usuario[0]["idUsuario"]
        user = Usuario.getUsuario(iduser)

        return user
예제 #12
0
    def getProdes():
        d = BD().run("Select * from Prode;")

        lista_aux = []

        for item in d:
            lista_aux.append(item)

        return lista_aux
예제 #13
0
def main():
    ins = RFID()
    data = BD()
    ins.init_serial()
    print("Iniciando Serial:\n {}".format(ins.serial))
    time.sleep(5)
    while True:
        data_serial = ins.get_id()
        print("'{}'".format(data_serial))
        data.insert_data(data_serial)
    def deletePais(self):

        contLigas = BD().run(
            "Select count(*) from Liga where Pais_idPais = '" + str(self.id) +
            "';")

        cont1 = None

        for item in contLigas:

            cont1 = item["count(*)"]

        if (cont1 == 0):

            BD().run("Delete from Pais Where idPais ='" + str(self.id) + "';")

        else:

            print("No se puede eliminar porque tiene Ligas asociados al Pais")
    def getEquipos():

        d = BD().run("Select * from Equipo;")

        lista_aux = []

        for item in d:
            lista_aux.append(item)

        return lista_aux
    def updateLiga(self):

        if self.campeon is None:

            self.campeon = "null"

        BD().run("update Liga Set Nombre = '" + self.nombre + "', Pais = '" +
                 self.pais + "', idEquipo_Campeon = " + str(self.campeon) +
                 ", Terminada= " + str(self.terminada) + ", Año = '" +
                 str(self.anio) + "' where idLiga = '" + str(self.id) + "';")
    def updateDT(self):

        BD().run("Update Persona set Nombre ='" + self.nombre +
                 "', Apellido = '" + self.apellido + "', Tipo = 'DT', Dni= '" +
                 str(self.dni) + "', Equipo_idEquipo = '" +
                 str(self.idEquipoPertenece) + "', Salario = '" +
                 str(self.salario) + "', Clausula = '" + str(self.clausula) +
                 "', Tactica_Preferida = '" + self.tactica_preferida +
                 "', Fecha_Nacimiento = '" + str(self.fecha_nacimiento) +
                 "' Where idPersona = '" + str(self.id) + "';")
    def getUsuarios():

        d = BD().run("Select * from Usuario;")

        lista_aux = []

        for item in d:
            lista_aux.append(item)

        return lista_aux
    def getLiga(unID):
        d = BD().run("Select * from Liga where idLiga = '" + str(unID) + "';")
        lista = d.fetchall()
        UnLiga = Liga()

        UnLiga.id = lista[0]["idLiga"]
        UnLiga.nombre = lista[0]["Nombre"]
        UnLiga.IDPaisPertenecer = lista[0]["Pais_idPais"]

        return UnLiga
예제 #20
0
 def __E(self, c):
     """
     E function that used BD algorithm and calculate the loss of the result
     :param c: the initial state
     :return: the loss score
     """
     bd = BD(10, self.__kt, self.__dt, c, 2, self.__protein_dict,
             self.__protein_vec, self.__df)
     res, bars = bd.BD_algorithm()
     return self.__loss(bars)
예제 #21
0
    def getCopas():

        d = BD().run("Select * from Copa;")

        lista_aux = []

        for item in d:

            lista_aux.append(item)

        return lista_aux
예제 #22
0
    def getCopa(unID):

        d = BD().run("Select * from Copa Where idCopa = '" + str(unID) + "';")
        lista = d.fetchall()
        UnaCopa = Copa()

        UnaCopa.id = lista[0]["idCopa"]
        UnaCopa.nombre = lista[0]["Nombre"]
        UnaCopa.IDOrgPertenecer = lista[0]["Organizacion_idOrganizacion"]

        return UnaCopa
    def setDT(self):

        cursor = BD().run(
            "Insert Into Persona(idPersona, Nombre, Apellido, Tipo, Dni, Equipo_idEquipo, Salario, Clausula, Tactica_Preferida, Fecha_Nacimiento, Posicion, Numero, Patrocinador) values(null,'"
            + self.nombre + "', '" + self.apellido + "', 'DT', '" +
            str(self.dni) + "', '" + str(self.idEquipoPertenece) + "', '" +
            str(self.salario) + "', '" + str(self.clausula) + "', '" +
            self.tactica_preferida + "','" + str(self.fecha_nacimiento) +
            "',null,null,null);")

        self.id = cursor.lastrowid
    def getDTs():

        d = BD().run("select * from Persona where Tipo = 'DT';")

        lista_aux = []

        for item in d:

            lista_aux.append(item)

        return lista_aux
예제 #25
0
    def getOrganizacion(unID):

        d=BD().run("select * from Organizacion Where idOrganizacion = '"+str(unID)+"';")
        lista = d.fetchall()
        unaOrg=Organizacion()


        unaOrg.id = lista[0]["idOrganizacion"]
        unaOrg.nombre= lista[0]["Nombre"]
        unaOrg.continente=lista[0]["Continente"]
        return unaOrg
예제 #26
0
    def getPartidos():

        d = BD().run("Select * from Partido;")

        lista_aux = []

        for item in d:

            lista_aux.append(item)

        return lista_aux
    def getLigas():

        d = BD().run("select * from Liga;")

        lista_aux = []

        for item in d:

            lista_aux.append(item)

        return lista_aux
    def getPais(unID):

        d = BD().run("Select * from Pais where idPais = '" + str(unID) + "';")
        lista = d.fetchall()
        UnPais = Pais()

        UnPais.id = lista[0]["idPais"]
        UnPais.nombre = lista[0]["Nombre"]
        UnPais.IDOrgPertenecer = lista[0]["Organizacion_idOrganizacion"]

        return UnPais
예제 #29
0
    def getOrganizaciones():

        d=BD().run("select * from Organizacion;")

        lista_aux=[]

        for item in d:

            lista_aux.append(item)

        return lista_aux
    def deleteEquipo(self):

        contadorPartido = BD().run(
            "select count(*) from Partido where idEquipo1 = '" + str(self.id) +
            "';")
        contadorPartido1 = BD().run(
            "select count(*) from Partido where idEquipo2 = '" + str(self.id) +
            "';")

        # contadorHinchas = BD().run("select count(*) from Usuario where Equipo_idEquipo = '" + str(self.id) + "';")

        cont1 = None

        for item in contadorPartido:
            cont1 = item["count(*)"]

        cont2 = None

        for item in contadorPartido1:
            cont2 = item["count(*)"]

        # cont3 = None
        #
        # for item in contadorHinchas:
        #
        #     cont3 = item["count(*)"]
        #
        if cont1 == 0 and cont2 == 0:

            BD().run("delete from DatosLiga Where Equipo_idEquipo = '" +
                     str(self.id) + "';")
            BD().run("delete from DatosCopa Where Equipo_idEquipo = '" +
                     str(self.id) + "';")
            BD().run("delete from Equipo Where idEquipo = '" + str(self.id) +
                     "';")

            return True

        else:

            return False