示例#1
0
def suggest_analysis_layout(solid_runs):
    """Generate a bash script to build the analysis directory scheme

    Given a set of SolidRuns, print a set of script commands for running the
    build_analysis_dir.py program to create and populate the analysis directories.

    The script can be edited before being executed by the user.

    Arguments:
      solid_runs: a list of SolidRun objects.
    """
    print("#!/bin/sh\n#\n# Script commands to build analysis directory structure")
    for run in solid_runs:
        build_analysis_dir_cmd = 'build_analysis_dir.py'
        top_dir = os.path.abspath(os.path.join(os.getcwd(),os.path.basename(run.run_dir)))
        for sample in run.samples:
            for project in sample.projects:
                # Create one experiment per project
                cmd_line = []
                expt = Experiment.Experiment()
                expt.name = project.getProjectName()
                expt.type = "expt"
                expt.sample = project.getSample().name
                expt.library = project.getLibraryNamePattern()
                # Print the arguments for the layout
                cmd_line.extend((build_analysis_dir_cmd,
                                 "--top-dir=%s_analysis" % top_dir,
                                 "--link=absolute",
                                 "--naming-scheme=partial"))
                cmd_line.append(expt.describe())
                cmd_line.append(run.run_dir)
                print("#\n%s" % (' \\\n').join(cmd_line))
示例#2
0
        print "    each experiment."
        print ""
        print "For each experiment defined on the command line, a subdirectory"
        print "called '<name>_<expt_type>' (e.g. 'PB_ChIP-seq' - if no <expt_type>"
        print "was supplied then just the name is used) will be made, and links to"
        print "each of the primary data files."
        sys.exit(1)

    # Solid run directory
    solid_run_dir = sys.argv[-1]
    if not os.path.isdir(solid_run_dir):
        logging.error("Solid run directory '%s' not found" % solid_run_dir)
        sys.exit(1)

    # Set up experiment list
    expts = Experiment.ExperimentList(solid_run_dir=solid_run_dir)

    # Process command line arguments
    for arg in sys.argv[1:-1]:
        # Process command line arguments
        if arg.startswith('--name='):
            expt_name = arg.split('=')[1]
            expt = expts.addExperiment(expt_name)
        elif arg.startswith('--type='):
            expt = expts.getLastExperiment()
            if expt is None:
                logging.error("No experiment defined for --type argument")
                sys.exit(1)
            if not expt.type:
                expt.type = arg.split('=')[1]
            else: