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)
示例#2
0
 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)
示例#3
0
if __name__ == "__main__":
    p = optparse.OptionParser(usage="%prog DIR [PROJECT]")
    p.add_option("-i","--init",action="store_true",dest="init",default=False,
                 help="initialise metadata file for the selected project (nb can "
                 "only be applied to one project at a time)")
    p.add_option("-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)")
    opts,args = p.parse_args()
    if not args or len(args) > 2:
        p.error("Need to supply a run directory and an optional project name")
    # Try and load the data
    try:
        run = AnalysisDir(args[0])
        print "Loaded data from %s" % args[0]
        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,ex:
        sys.stderr.write("Failed to load data for %s: %s\n" % (args[0],ex))
        sys.exit(1)
    # Aquire the projects
    try:
        target_project = args[1]
    except IndexError:
        target_project = None
    projects = run.get_projects(pattern=target_project)
    if not projects:
示例#4
0
    # 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)