raise GenestackException( "The key '%s' must be supplied in the CSV file" % mandatory_key) for file_data in reader: # for each entry, prepare a BioMetainfo object metainfo = BioMetainfo() for key in field_names: # 'link' and 'organism' are treated separately, as they are added to the metainfo using specific methods if key == "link": url = file_data[key] metainfo.add_external_link(key=BioMetainfo.READS_LINK, text="link", url=url, fmt=file_format) elif key == "organism": metainfo.add_organism(BioMetainfo.ORGANISM, file_data[key]) # all the other keys are added as strings else: metainfo_key = SPECIAL_KEYS.get(key.lower(), key) metainfo.add_string(metainfo_key, file_data[key]) # create the sequencing assay on Genestack created_file = importer.create_sequencing_assay(experiment, metainfo=metainfo) print "Created file '%s' (%s)" % (file_data['name'], created_file) print "All done! Bye now..."
reader = csv.DictReader(the_file, delimiter=",") field_names = reader.fieldnames # check if mandatory keys are in the CSV file for mandatory_key in MANDATORY_KEYS: if mandatory_key not in field_names: raise GenestackException("The key '%s' must be supplied in the CSV file" % mandatory_key) for file_data in reader: # for each entry, prepare a BioMetainfo object metainfo = BioMetainfo() for key in field_names: # 'link' and 'organism' are treated separately, as they are added to the metainfo using specific methods if key == "link": url = file_data[key] metainfo.add_external_link(key=BioMetainfo.READS_LINK, text="link", url=url, fmt=file_format) elif key == "organism": metainfo.add_organism(BioMetainfo.ORGANISM, file_data[key]) # all the other keys are added as strings else: metainfo_key = SPECIAL_KEYS.get(key.lower(), key) metainfo.add_string(metainfo_key, file_data[key]) # create the sequencing assay on Genestack created_file = importer.create_sequencing_assay(experiment, metainfo=metainfo) print "Created file '%s' (%s)" % (file_data['name'], created_file) print "All done! Bye now..."
# find the corresponding file local_identifier = file_data[local_key] remote_file = identifier_map.get(local_identifier) if not remote_file: print "Warning: no match found for file name '%s'" % local_identifier continue # prepare a BioMetainfo object metainfo = BioMetainfo() for key in field_names: # key parsing logic value = file_data[key] if value == "" or value is None: continue if key == args.local_key: continue if key == "organism": metainfo.add_organism(BioMetainfo.ORGANISM, value) else: metainfo_key = SPECIAL_KEYS.get(key.lower(), key) if parse_as_boolean(value) is not None: metainfo.add_boolean(metainfo_key, parse_as_boolean(value)) else: metainfo.add_string(metainfo_key, value) # edit the metadata on Genestack files_util.add_metainfo_values(remote_file, metainfo) print "Edited metainfo for '%s' (%s)" % (local_identifier, remote_file) print "All done!"
remote_file = identifier_map.get(local_identifier) if not remote_file: print "Warning: no match found for file name '%s'" % local_identifier continue # prepare a BioMetainfo object metainfo = BioMetainfo() for key in field_names: # key parsing logic value = file_data[key] if value == "" or value is None: continue if key == args.local_key: continue if key == "organism": metainfo.add_organism(BioMetainfo.ORGANISM, value) else: metainfo_key = SPECIAL_KEYS.get(key.lower(), key) if parse_as_boolean(value) is not None: metainfo.add_boolean(metainfo_key, parse_as_boolean(value)) else: metainfo.add_string(metainfo_key, value) # edit the metadata on Genestack files_util.add_metainfo_values(remote_file, metainfo) print "Edited metainfo for '%s' (%s)" % (local_identifier, remote_file) print "All done!"