Exemplo n.º 1
0
 def project_from_dir(d):
     project = RunfolderProject(name=os.path.basename(d),
                                path=os.path.join(projects_base_dir, d),
                                runfolder_path=runfolder.path,
                                runfolder_name=runfolder.name)
     project.project_files = self.get_report_files(
         project, checksums=runfolder.checksums)
     project.samples = self.sample_repository.get_samples(
         project, runfolder)
     return project
Exemplo n.º 2
0
        def project_from_dir(d):
            project = RunfolderProject(name=os.path.basename(d),
                                       path=os.path.join(projects_base_dir, d),
                                       runfolder_path=runfolder.path,
                                       runfolder_name=runfolder.name)
            try:
                project.project_files = self.get_report_files(
                    project, checksums=runfolder.checksums)
            except ProjectReportNotFoundException as e:
                log.warning(e)

            project.samples = self.sample_repository.get_samples(
                project, runfolder)
            return project
Exemplo n.º 3
0
    def organise_project(self, runfolder, project, organised_projects_path,
                         lanes):
        """
        Organise a project on a runfolder into its own directory and into a standard structure. If the project has
        already been organised, a ProjectAlreadyOrganisedException will be raised, unless force is True. If force is
        True, the existing project path will be renamed with a unique suffix.

        :param runfolder: a Runfolder instance representing the runfolder on which the project belongs
        :param project: a Project instance representing the project to be organised
        :param lanes: if not None, only samples on any of the specified lanes will be organised
        :param force: if True, a previously organised project will be renamed with a unique suffix
        :raises ProjectAlreadyOrganisedException: if project has already been organised and force is False
        :return: a Project instance representing the project after organisation
        """
        # symlink the samples
        organised_project_path = os.path.join(organised_projects_path,
                                              project.name)
        organised_project_runfolder_path = os.path.join(
            organised_project_path, runfolder.name)
        organised_samples = []
        for sample in project.samples:
            organised_samples.append(
                self.organise_sample(sample, organised_project_runfolder_path,
                                     lanes))
        # symlink the project files
        organised_project_files = []
        if project.project_files:
            project_file_base = self.file_system_service.dirname(
                project.project_files[0].file_path)
            for project_file in project.project_files:
                organised_project_files.append(
                    self.organise_project_file(
                        project_file,
                        organised_project_runfolder_path,
                        project_file_base=project_file_base))
        organised_project = RunfolderProject(project.name,
                                             organised_project_path,
                                             runfolder.path,
                                             runfolder.name,
                                             samples=organised_samples)
        organised_project_files.append(
            self.runfolder_service.dump_project_samplesheet(
                runfolder, organised_project))
        organised_project.project_files = organised_project_files
        self.runfolder_service.dump_project_checksums(organised_project)

        return organised_project
Exemplo n.º 4
0
def runfolder_project(runfolder,
                      project_name="ABC_123",
                      sample_indexes=sample_index_generator(),
                      lane_numbers=lane_generator(),
                      project_root="Unaligned",
                      report_type=report_type_generator()):
    project = RunfolderProject(name=project_name,
                               path=os.path.join(runfolder.path, project_root,
                                                 project_name),
                               runfolder_path=runfolder.path,
                               runfolder_name=runfolder.name)
    project.project_files = project_report_files(project, next(report_type))
    sample_names = sample_name_generator()

    # a straight-forward sample with files on one lane
    lane_number = next(lane_numbers)
    samples = [
        project_sample(project, next(sample_names), next(sample_indexes),
                       lane_number)
    ]

    # a sample with files on two lanes
    sample_name = next(sample_names)
    sample_index = next(sample_indexes)
    sample = project_sample(project, sample_name, sample_index, lane_number)
    lane_number = next(lane_numbers)
    t_sample = project_sample(project, sample_name, sample_index, lane_number)
    sample.sample_files.extend(t_sample.sample_files)
    samples.append(sample)

    # a sample with two preps on two lanes and sample files in subdirectories
    sample_name = next(sample_names)
    t_samples = [
        project_sample(project,
                       sample_name=sample_name,
                       sample_index=si,
                       lane_no=l,
                       sample_id="{}-{}-{}".format(sample_name, si, l))
        for si in [next(sample_indexes),
                   next(sample_indexes)]
        for l in [next(lane_numbers), next(lane_numbers)]
    ]
    samples.extend(t_samples)

    project.samples = samples
    return project