def generate_expand_search_database_from_contigs(self, contig_files, output_database_file, <EOL>search_method):
ss = SequenceSearcher(self.search_hmm_files)<EOL>seqio = SequenceIO()<EOL>if search_method == self.DIAMOND_SEARCH_METHOD:<EOL><INDENT>if self.diamond_database == None or self.unaligned_sequence_database == None:<EOL><INDENT>logging.warning("<STR_LIT>") <EOL>return False<EOL><DEDENT><DEDENT>with tempfile.NamedTemporaryFile(prefix='<STR_LIT>') as orfs:<EOL><INDENT>logging.info("<STR_LIT>")<EOL>for contig_file in contig_files:<EOL><INDENT>logging.debug("<STR_LIT>" % contig_file)<EOL>unpack = UnpackRawReads(contig_file)<EOL>with tempfile.NamedTemporaryFile(prefix='<STR_LIT>') ashit_reads_orfs_fasta:<EOL><INDENT>with tempfile.NamedTemporaryFile(prefix='<STR_LIT>') ashmmsearch_output_table:<EOL><INDENT>with tempfile.NamedTemporaryFile(prefix='<STR_LIT>') ashit_reads_fasta:<EOL><INDENT>ss.search_and_extract_orfs_matching_protein_database(unpack,<EOL>search_method,<EOL>self.maximum_range,<EOL>self.threads,<EOL>self.evalue,<EOL>self.min_orf_length,<EOL>None,<EOL>(self.diamond_database if self.diamond_database else None),<EOL>hmmsearch_output_table.name,<EOL>hit_reads_fasta.name,<EOL>hit_reads_orfs_fasta.name)<EOL><DEDENT><DEDENT>shutil.copyfileobj(open(hit_reads_orfs_fasta.name), orfs)<EOL><DEDENT><DEDENT>orfs.flush()<EOL>with tempfile.NamedTemporaryFile(prefix="<STR_LIT>") as aln:<EOL><INDENT>if search_method == self.HMM_SEARCH_METHOD:<EOL><INDENT>if len(seqio.read_fasta_file(orfs.name)) <= <NUM_LIT:1>:<EOL><INDENT>logging.warn("<STR_LIT>")<EOL>return False<EOL><DEDENT>cmd = "<STR_LIT>" % (orfs.name, aln.name)<EOL>logging.info("<STR_LIT>")<EOL>extern.run(cmd)<EOL>cmd = "<STR_LIT>" % (output_database_file, aln.name)<EOL>logging.info("<STR_LIT>")<EOL>extern.run(cmd)<EOL><DEDENT>elif search_method == self.DIAMOND_SEARCH_METHOD:<EOL><INDENT>with tempfile.NamedTemporaryFile(prefix="<STR_LIT>") as databasefile:<EOL><INDENT>for f in [orfs.name, self.unaligned_sequence_database]:<EOL><INDENT>for line in open(f):<EOL><INDENT>databasefile.write(line)<EOL><DEDENT><DEDENT>databasefile.flush()<EOL>cmd = "<STR_LIT>" % (databasefile.name, output_database_file)<EOL>logging.info("<STR_LIT>")<EOL>extern.run(cmd)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>" % search_method)<EOL>return False<EOL><DEDENT>return True<EOL><DEDENT><DEDENT>
Given a collection of search_hmm_files, search the contigs in 
        contig_files, and generate an HMM from the resulting hits, outputting
        it as output_database_file.

        Parameters
        ----------
        contig_files: list of str
            list of files to search
        output_database_file: str
            path to output file
        search_method: str
            "diamond" or "hmmsearch", to specify search method to use and what
            type of database to build. 

        Returns
        -------
        True if genes were recovered, else False