<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_sargasso_logs(self, f):
 """ Parse the sargasso log file. """

        species_name = list()
        items = list()
        header = list()
        is_first_line = True
        for l in f['f'].splitlines():
            s = l.split(",")
            # Check that this actually is a Sargasso file
            if is_first_line and s[0]!='Sample':
                return None

            if len(s) < 7:
                continue
            if is_first_line:
                #prepare header
                is_first_line = False
                header = s
                for i in header[1:]:
                    #find out what species included
                    sname = i.split('-')[-1]
                    if sname not in species_name:
                        species_name.append(sname)
                    #find out what is being counted
                    kname = ("-".join(i.split('-')[-3:-1]))
                    if kname not in items:
                        items.append(kname)
            else:
                #start sample lines.
                sample_name = s.pop(0)

                chunk_by_species = [s[i:i + len(items)] for i in range(0, len(s), len(items))];
                for idx,v in enumerate(chunk_by_species):
                    #adding species name to the sample name for easy interpretation
                    new_sample_name = '_'.join([sample_name,species_name[idx]])

                    # Clean up sample name
                    new_sample_name = self.clean_s_name(new_sample_name, f['root'])

                    if new_sample_name in self.sargasso_data.keys():
                        log.debug("Duplicate sample name found! Overwriting: {}".format(new_sample_name))

                    try:
                        self.sargasso_data[new_sample_name] = dict(zip(items,map(int, v)))
                    except ValueError:
                        pass



        self.sargasso_keys = items

        for idx, f_name in enumerate(self.sargasso_data.keys()):



            # Reorganised parsed data for this sample
            # Collect total READ count number
            self.sargasso_data[f_name]['Total'] = 0;
            for key, value in list(self.sargasso_data[f_name].items()):   # iter on both keys and values
                if key.endswith("Reads"):
                    self.sargasso_data[f_name]['Total'] += value

            # Calculate the percent aligned if we can
            try:
                self.sargasso_data[f_name]['sargasso_percent_assigned'] = (float(self.sargasso_data[f_name]['Assigned-Reads'])/float(self.sargasso_data[f_name]['Total'])) * 100.0
            except (KeyError, ZeroDivisionError):
                pass