humann/store.py
def process_file(self, file):
        """
        Process the file and yield ids and sequences
        """
        
        # Check the file exists and is readable
        utilities.file_exists_readable(file)
            
        # Check that the file of reads is fasta
        # If it is fastq, then convert the file to fasta
        temp_file=""
        if utilities.fasta_or_fastq(file) == "fastq":
            input_fasta=utilities.fastq_to_fasta(file)
            temp_file=input_fasta
        else:
            input_fasta=file
                       
        file_handle=open(input_fasta,"rt")
            
        sequence=""
        id=""
        for line in file_handle:
            if re.search("^>", line):
                # store the prior sequence
                if id:
                    yield (id,sequence)
                id=line.rstrip().replace(">","")
                # only store the first id if multiple separated by spaces
                if " " in id:
                    ids=id.split(" ")
                    id=ids[0]
                sequence=""
            else:
                sequence+=line.rstrip()
            
        # add the last sequence
        yield (id, sequence)
                
        file_handle.close()
            
        # Remove the temp fasta file if exists
        if temp_file:
            utilities.remove_file(temp_file)

        Process the file and yield ids and sequences
        
Process the file and yield ids and sequences
Process the file and yield ids and sequences
def process_file(self, file):
        utilities.file_exists_readable(file)
        temp_file=""
        if utilities.fasta_or_fastq(file) == "fastq":
            input_fasta=utilities.fastq_to_fasta(file)
            temp_file=input_fasta
        else:
            input_fasta=file
        file_handle=open(input_fasta,"rt")
        sequence=""
        id=""
        for line in file_handle:
            if re.search("^>", line):
                if id:
                    yield (id,sequence)
                id=line.rstrip().replace(">","")
                if " " in id:
                    ids=id.split(" ")
                    id=ids[0]
                sequence=""
            else:
                sequence+=line.rstrip()
        yield (id, sequence)
        file_handle.close()
        if temp_file:
            utilities.remove_file(temp_file)
def process_file ( self , file ) : utilities . file_exists_readable ( file ) temp_file = "" if utilities . fasta_or_fastq ( file ) == "fastq" : input_fasta = utilities . fastq_to_fasta ( file ) temp_file = input_fasta else : input_fasta = file file_handle = open ( input_fasta , "rt" ) sequence = "" id = "" for line in file_handle : if re . search ( "^>" , line ) : if id : yield ( id , sequence ) id = line . rstrip ( ) . replace ( ">" , "" ) if " " in id : ids = id . split ( " " ) id = ids [ 0 ] sequence = "" else : sequence += line . rstrip ( ) yield ( id , sequence ) file_handle . close ( ) if temp_file : utilities . remove_file ( temp_file )
Process the file and yield ids and sequences
Process the file and yield ids and sequences
"""
        Process the file and yield ids and sequences
        """ # Check the file exists and is readable # Check that the file of reads is fasta # If it is fastq, then convert the file to fasta # store the prior sequence # only store the first id if multiple separated by spaces # add the last sequence # Remove the temp fasta file if exists
self
file