def search(self):
        self.search_terms = parser.parse(self.search_terms)
        print("After parsing:", self.search_terms)

        for a_search in self.search_terms:
            print("[kodak] item is:", pf(a_search))
            search_term = a_search['search_term']
            search_operator = a_search['separator']
            if a_search['key']:
                search_type = a_search['key'].upper()
            else:
                # We fall back to the dataset type as the key to get the right object
                search_type = self.dataset.type
                
            print("search_type is:", pf(search_type))

            # This is throwing an error when a_search['key'] is None, so I changed above    
            #search_type = string.upper(a_search['key'])
            #if not search_type:
            #    search_type = self.dataset.type

            search_ob = do_search.DoSearch.get_search(search_type)
            search_class = getattr(do_search, search_ob)
            print("search_class is: ", pf(search_class))
            the_search = search_class(search_term,
                                    search_operator,
                                    self.dataset,
                                    )
            self.results.extend(the_search.run())
            #print("in the search results are:", self.results)

        self.header_fields = the_search.header_fields
Example #2
0
    def search(self):
        """This function sets up the actual search query in the form of a SQL
statement and executes

        """
        self.search_terms = parser.parse(self.search_terms)
        logger.debug("After parsing:", self.search_terms)

        if len(self.search_terms) > 1:
            logger.debug("len(search_terms)>1")
            combined_from_clause = ""
            combined_where_clause = ""
            previous_from_clauses = [
            ]  #The same table can't be referenced twice in the from clause
            for i, a_search in enumerate(self.search_terms):
                the_search = self.get_search_ob(a_search)
                if the_search != None:
                    get_from_clause = getattr(the_search, "get_from_clause",
                                              None)
                    if callable(get_from_clause):
                        from_clause = the_search.get_from_clause()
                        if from_clause in previous_from_clauses:
                            pass
                        else:
                            previous_from_clauses.append(from_clause)
                            combined_from_clause += from_clause
                    where_clause = the_search.get_where_clause()
                    combined_where_clause += "(" + where_clause + ")"
                    if (i + 1) < len(self.search_terms):
                        if self.and_or == "and":
                            combined_where_clause += "AND"
                        else:
                            combined_where_clause += "OR"
                else:
                    logger.debug("Search failed 1")
                    self.search_term_exists = False
            if self.search_term_exists:
                combined_where_clause = "(" + combined_where_clause + ")"
                final_query = the_search.compile_final_query(
                    combined_from_clause, combined_where_clause)
                # logger.debug("final_query",final_query)
                results = the_search.execute(final_query)
                self.results.extend(results)
        else:
            logger.debug("len(search_terms)<=1")
            if self.search_terms == []:
                logger.debug("Search failed 2")
                self.search_term_exists = False
            else:
                for a_search in self.search_terms:
                    the_search = self.get_search_ob(a_search)
                    if the_search != None:
                        self.results.extend(the_search.run())
                    else:
                        logger.debug("Search failed 3")
                        self.search_term_exists = False

        if self.search_term_exists:
            if the_search != None:
                self.header_fields = the_search.header_fields
    def search(self):
        """This function sets up the actual search query in the form of a SQL
statement and executes

        """
        self.search_terms = parser.parse(self.search_terms)
        logger.debug("After parsing:", self.search_terms)

        if len(self.search_terms) > 1:
            logger.debug("len(search_terms)>1")
            combined_from_clause = ""
            combined_where_clause = ""
            previous_from_clauses = [] #The same table can't be referenced twice in the from clause
            for i, a_search in enumerate(self.search_terms):
                the_search = self.get_search_ob(a_search)
                if the_search != None:
                    get_from_clause = getattr(the_search, "get_from_clause", None)
                    if callable(get_from_clause):
                        from_clause = the_search.get_from_clause()
                        if from_clause in previous_from_clauses:
                            pass
                        else:
                            previous_from_clauses.append(from_clause)
                            combined_from_clause += from_clause
                    where_clause = the_search.get_where_clause()
                    combined_where_clause += "(" + where_clause + ")"
                    if (i+1) < len(self.search_terms):
                        if self.and_or == "and":
                            combined_where_clause += "AND"
                        else:
                            combined_where_clause += "OR"
                else:
                    logger.debug("Search failed 1")
                    self.search_term_exists = False
            if self.search_term_exists:
                combined_where_clause = "(" + combined_where_clause + ")"
                final_query = the_search.compile_final_query(combined_from_clause, combined_where_clause)
                # logger.debug("final_query",final_query)
                results = the_search.execute(final_query)
                self.results.extend(results)
        else:
            logger.debug("len(search_terms)<=1")
            if self.search_terms == []:
                logger.debug("Search failed 2")
                self.search_term_exists = False
            else:
                for a_search in self.search_terms:
                    the_search = self.get_search_ob(a_search)
                    if the_search != None:
                        self.results.extend(the_search.run())
                    else:
                        logger.debug("Search failed 3")
                        self.search_term_exists = False

        if self.search_term_exists:
            if the_search != None:
                self.header_fields = the_search.header_fields
Example #4
0
    def search(self):
        self.search_terms = parser.parse(self.search_terms)
        print("After parsing:", self.search_terms)

        if len(self.search_terms) > 1:
            combined_from_clause = ""
            combined_where_clause = ""
            previous_from_clauses = [
            ]  #The same table can't be referenced twice in the from clause
            for i, a_search in enumerate(self.search_terms):
                the_search = self.get_search_ob(a_search)
                if the_search != None:
                    get_from_clause = getattr(the_search, "get_from_clause",
                                              None)
                    if callable(get_from_clause):
                        from_clause = the_search.get_from_clause()
                        if from_clause in previous_from_clauses:
                            pass
                        else:
                            previous_from_clauses.append(from_clause)
                            combined_from_clause += from_clause
                    where_clause = the_search.get_where_clause()
                    combined_where_clause += "(" + where_clause + ")"
                    if (i + 1) < len(self.search_terms):
                        if self.and_or == "and":
                            combined_where_clause += "AND"
                        else:
                            combined_where_clause += "OR"
                else:
                    self.search_term_exists = False
            if self.search_term_exists:
                combined_where_clause = "(" + combined_where_clause + ")"
                final_query = the_search.compile_final_query(
                    combined_from_clause, combined_where_clause)
                results = the_search.execute(final_query)
                self.results.extend(results)
        else:
            if self.search_terms == []:
                self.search_term_exists = False
            else:
                for a_search in self.search_terms:
                    the_search = self.get_search_ob(a_search)
                    if the_search != None:
                        self.results.extend(the_search.run())
                    else:
                        self.search_term_exists = False

        if self.search_term_exists:
            if the_search != None:
                self.header_fields = the_search.header_fields
    def search(self):
        self.search_terms = parser.parse(self.search_terms)
        print("After parsing:", self.search_terms)

        if len(self.search_terms) > 1:
            combined_from_clause = ""
            combined_where_clause = "" 
            previous_from_clauses = [] #The same table can't be referenced twice in the from clause
            for i, a_search in enumerate(self.search_terms):
                the_search = self.get_search_ob(a_search)
                if the_search != None:
                    get_from_clause = getattr(the_search, "get_from_clause", None)
                    if callable(get_from_clause):
                        from_clause = the_search.get_from_clause()
                        if from_clause in previous_from_clauses:
                            pass
                        else:
                            previous_from_clauses.append(from_clause)
                            combined_from_clause += from_clause
                    where_clause = the_search.get_where_clause()
                    combined_where_clause += "(" + where_clause + ")"
                    if (i+1) < len(self.search_terms):
                        if self.and_or == "and":
                            combined_where_clause += "AND"
                        else:
                            combined_where_clause += "OR"
                else:
                    self.search_term_exists = False
            if self.search_term_exists:
                combined_where_clause = "(" + combined_where_clause + ")"
                final_query = the_search.compile_final_query(combined_from_clause, combined_where_clause)
                results = the_search.execute(final_query)
                self.results.extend(results)
        else:
            if self.search_terms == []:
                self.search_term_exists = False
            else:
                for a_search in self.search_terms:
                    the_search = self.get_search_ob(a_search)
                    if the_search != None:
                        self.results.extend(the_search.run())
                    else:
                        self.search_term_exists = False

        if self.search_term_exists:
            if the_search != None:
                self.header_fields = the_search.header_fields
    def search(self):
        """
        This function sets up the actual search query in the form of a SQL statement and executes

        """
        self.search_terms = parser.parse(self.search_terms)

        combined_from_clause = ""
        combined_where_clause = ""
        # The same table can't be referenced twice in the from clause
        previous_from_clauses = []

        symbol_list = []
        if self.dataset.type == "ProbeSet":
            for a_search in self.search_terms:
                if a_search['key'] == None:
                    symbol_list.append(a_search['search_term'][0])

            alias_terms = get_aliases(symbol_list, self.dataset.group.species)

            for i, a_search in enumerate(alias_terms):
                the_search = self.get_search_ob(a_search)
                if the_search != None:
                    get_from_clause = getattr(
                        the_search, "get_from_clause", None)
                    if callable(get_from_clause):
                        from_clause = the_search.get_from_clause()
                        if from_clause in previous_from_clauses:
                            pass
                        else:
                            previous_from_clauses.append(from_clause)
                            combined_from_clause += from_clause
                    where_clause = the_search.get_alias_where_clause()
                    combined_where_clause += "(" + where_clause + ")"
                    if self.and_or == "and":
                        combined_where_clause += "AND"
                    else:
                        combined_where_clause += "OR"

        for i, a_search in enumerate(self.search_terms):
            if a_search['key'] == "GO":
                self.go_term = a_search['search_term'][0]
                gene_list = get_GO_symbols(a_search)
                self.search_terms += gene_list
                continue
            else:
                the_search = self.get_search_ob(a_search)
                if the_search != None:
                    get_from_clause = getattr(
                        the_search, "get_from_clause", None)
                    if callable(get_from_clause):
                        from_clause = the_search.get_from_clause()
                        if from_clause in previous_from_clauses:
                            pass
                        else:
                            previous_from_clauses.append(from_clause)
                            combined_from_clause += from_clause
                    where_clause = the_search.get_where_clause()
                    combined_where_clause += "(" + where_clause + ")"
                    if (i + 1) < len(self.search_terms):
                        if self.and_or == "and":
                            combined_where_clause += "AND"
                        else:
                            combined_where_clause += "OR"
                else:
                    self.search_term_exists = False
        if self.search_term_exists:
            combined_where_clause = "(" + combined_where_clause + ")"
            final_query = the_search.compile_final_query(
                combined_from_clause, combined_where_clause)
            results = the_search.execute(final_query)
            self.results.extend(results)

        if self.search_term_exists:
            if the_search != None:
                self.header_fields = the_search.header_fields