help="explicitly specify subdirectory of DIR with " "Fastq files to run the QC on.") p.add_argument('--link', action='store_true', dest='link', default=False, help="hard link files instead of copying") options, args = p.parse_known_args() # Get analysis dir try: dirn = args[0] print("Loading data for analysis dir %s" % dirn) except IndexError: p.error("Need to supply the path to an analysis dir") sys.exit(1) analysis_dir = AnalysisDir(dirn) # Get specified project try: project_name = args[1] except IndexError: # List projects and exit print("Projects:") for project in analysis_dir.projects: print("%s" % project.name) if len(project.fastq_dirs) > 1: # List the fastq sets if there are more than one # and flag the primary set with an asterisk for d in project.fastq_dirs: is_primary = (d == project.info.primary_fastq_dir) print("- %s%s" % (d, (" *" if is_primary else ""))) if analysis_dir.undetermined:
help="initialise metadata file for the selected project " "(nb can only be applied to one project at a time)") p.add_argument("-u","--update", action="append",dest="update", help="update the metadata in the selected project by " "specifying key=value pairs e.g. user='******' " "(nb can only be applied to one project at a time)") p.add_argument("dir",metavar="DIR", help="analysis directory to update metadata for") p.add_argument("project",metavar="PROJECT", help="project within the analysis directory to update " "metadata for") args = p.parse_args() # Try and load the data try: run = AnalysisDir(args.dir) print("Loaded data from %s" % args.dir) print("Found %d projects" % run.n_projects) if run.undetermined is not None: print("Found 'undetermined' analysis") print("Found %d sequencing data directories" % run.n_sequencing_data) except Exception as ex: sys.stderr.write("Failed to load data for %s: %s\n" % (args.dir,ex)) sys.exit(1) # Aquire the projects target_project = args.project projects = run.get_projects(pattern=target_project) if not projects: print("No projects found") sys.exit(1) print("%d projects selected" % len(projects))
p.add_option("--pi",action='store',dest="pi_name",default=None, help="List data for PI(s) matching PI_NAME (can use glob-style " "patterns)") p.add_option("--unassigned",action='store_true',dest="unassigned",default=False, help="List data for projects where PI is not assigned") opts,args = p.parse_args() # Collect data audit_data = {} unassigned = [] undetermined = [] for d in args: for dirn in utils.list_dirs(d): dirn = os.path.join(d,dirn) #print "Examining %s" % dirn try: run = AnalysisDir(dirn) for p in run.get_projects(): if p.name == "undetermined": undetermined.append((p,get_size(p.dirn))) continue pi = p.info.PI if pi is None: # PI is not assigned p.info['run'] = os.path.basename(dirn) unassigned.append(p) continue elif opts.pi_name is not None: if not fnmatch.fnmatch(pi,opts.pi_name): # Skip non-matching name continue #print "\t%s: %s" % (p.name,pi)
# Collect arguments if len(args) != 4: p.error("Wrong args") galaxy_url = args[0] library_name = args[1] dest = args[2] rundir = args[3] # Subset of projects if opts.projects is not None: projects = opts.projects.split(',') else: projects = None # Get analysis dir analysis_dir = AnalysisDir(rundir) print "Run name: %s" % analysis_dir.run_name print "Run number: %s" % analysis_dir.metadata.run_number print "Date stamp: %s" % analysis_dir.date_stamp try: # Create the directory structure on the server build_library_directory(analysis_dir, dest, projects=projects) # Upload to the Galaxy instance create_data_library(galaxy_url, library_name, analysis_dir, dest, projects=projects, no_verify=opts.no_verify) except Exception as ex: logging.critical("Export failed: %s" % ex)