---------------------------- On Mon, Jan 19, 2015 3:32 PM CET jarod...@libero.it wrote:
>Dear All, >I would like to understand how work this funcion: > >def parse_illumina_readset_file(illumina_readset_file): > readsets = [] > samples = [] > > log.info("Parse readset " + illumina_readset_file + " ...") > readset_csv = csv.DictReader(open(illumina_readset_file, 'rb'), > delimiter='\t') > for line in readset_csv: > sample_name = line['Sample'] > sample_names = [sample.name for sample in samples] > if sample_name in sample_names: > # Sample already exists > sample = samples[sample_names.index(sample_name)] > else: > # Create new sample > sample = Sample(sample_name) > samples.append(sample) > > # Create readset and add it to sample > readset = IlluminaReadset(line['Readset'], line['RunType']) > > # Readset file paths are either absolute or relative to the readset > file > # Convert them to absolute paths > for format in ("BAM", "FASTQ1", "FASTQ2"): > if line.get(format, None): > line[format] = os.path.expandvars(line[format]) > if not os.path.isabs(line[format]): > line[format] = > os.path.dirname(os.path.abspath(os.path.expandvars(illumina_readset_file))) + > os.sep + line[format] > line[format] = os.path.normpath(line[format]) > > readset._bam = line.get('BAM', None) > readset.fastq1 = line.get('FASTQ1', None) > readset.fastq2 = line.get('FASTQ2', None) > readset._library = line.get('Library', None) > readset._run = line.get('Run', None) > readset._lane = line.get('Lane', None) > readset._adaptor1 = line.get('Adaptor1', None) > readset._adaptor2 = line.get('Adaptor2', None) > readset._quality_offset = int(line['QualityOffset']) if > line.get('QualityOffset', None) else None > readset._beds = line['BED'].split(";") if line.get('BED', None) else [] > > readsets.append(readset) > sample.add_readset(readset) > > log.info(str(len(readsets)) + " readset" + ("s" if len(readsets) > 1 else > ") + " parsed") > log.info(str(len(samples)) + " sample" + ("s" if len(samples) > 1 else ") > + " parsed\n") > return readsets > > >parser_illumina_readset_file("~/Desktop/file.csv") Too much code to read ony tiny phone screen, but I think you also need to wrap the filename in os.pat.expanduser to get tilde expansion. >dir() > >I can't found the readsets list. Someone could please help me? >thanks so much! > > > > >_______________________________________________ >Tutor maillist - Tutor@python.org >To unsubscribe or change subscription options: >https://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor