def get_couples_by_list_id(list_ids): """ return an array with all the couples in the database given an array with these ids :return: array of couple :rtype: array(Couple) """ listOfCouples = [] sqlObj = _Couple_sql_new() results = sqlObj.select_all_couples_all_attributes_by_arrays_ids(list_ids) for element in results: listOfCouples.append(Couple(element[0], element[1], element[2], element[3], element[4], element[5], element[6], element[7])) return listOfCouples
def remove_couple_by_id_bacterium(id_bacterium): """ remove a couple given its id_bacterium :param id_bacterium: id of the couple :type id_bacterium: int - required :return: couple it removed :rtype: int """ sqlObj = _Couple_sql_new() id_couple = sqlObj.remove_couple_by_fk_bacterium(id_bacterium) return id_couple
def verify_couple_exist_by_phage_bact(id_bact, id_phage): """ Verify if a couple exists by the couple of phage, bact :param id_bact: id of the couple :param id_phage: id of the couple :type id_bact: int - required :type id_bacterium: int - required :return: couple it removed :rtype: int """ sqlObj = _Couple_sql_new() id_couple = sqlObj.get_id_couple_by_phage_bact(id_bact, id_phage) return id_couple
def get_all_positive_couples_by_phage_id(fk_phage): """ return an array with all the positive couples in the database based on phage fk_id :param fk_phage: id of the phage - -1 if unknown :type fk_phage: int - required :return: array of couple :rtype: array(Couple) """ listOfCouples = [] sqlObj = _Couple_sql_new() results = sqlObj.select_all_positive_couples_all_attributes_by_fk_phage(fk_phage) for element in results: listOfCouples.append(Couple(element[0], element[1], element[2], element[3], element[4], element[5], element[6], element[7])) return listOfCouples
def get_all_couples_negative_by_bacterium_level(fk_bacterium, fk_level): """ return an array with all the couples in the database based on bacterium fk_id :param fk_bacterium: id of the bacterium - -1 if unknown :param fk_level: id of the interaction leve :type fk_bacterium: int - required :type fk_level: int - required :return: array of couple :rtype: array(Couple) """ listOfCouples = [] sqlObj = _Couple_sql_new() results = sqlObj.select_all_couples_all_attributes_by_fk_bacterium_level_type(fk_bacterium, fk_level, 2) for element in results: listOfCouples.append(Couple(element[0], element[1], element[2], element[3], element[4], element[5], element[6], element[7])) return listOfCouples
def create_couple(self): """ Insert a Couple in the database if it not already exits and update its id The Couple contain a : - Interaction - Bacterium - Phage - Type interaction - Level interaction - Level of lysis - Source of data :return: id of the Couple :rtype int """ value_couple = None sqlObj = _Couple_sql_new() value_couple = sqlObj.insert_couple_if_ot_exist(self.interact_pn, self.fk_bacteria, self.fk_phage, self.fk_type_inter, self.fk_level_interact, self.fk_lysis_inter, self.fk_source_data) self.id_couple = value_couple print(value_couple) return value_couple
def get_all_couples_by_type_level_source(interaction_type, fk_level, fk_source): """ return an array with all the couples in the database based on interaction type (positive or negative), level (specie, strain,...) and source (NCBI, Phages,...) :param interaction_type: id of the bacterium - -1 if unknown :param fk_level: id of the interaction leve :param fk_source: id of the interaction leve :type interaction_type: int - required :type fk_level: int - required :type fk_source: int - required :return: array of couple :rtype: array(Couple) """ listOfCouples = [] sqlObj = _Couple_sql_new() results = sqlObj.select_all_couples_all_attributes_by_type_level_source(interaction_type, fk_level, fk_source) for element in results: listOfCouples.append(Couple(element[0], element[1], element[2], element[3], element[4], element[5], element[6], element[7])) return listOfCouples