Ejemplo n.º 1
0
 def construct_sample_sheet(self) -> str:
     """Construct the sample sheet"""
     LOG.info("Constructing sample sheet for %s", self.flowcell_id)
     # Create dummy samples for the indexes that is missing
     if self.run_parameters.run_type == "wgs":
         self.add_dummy_samples()
     else:
         LOG.info("Skip adding dummy samples since run is not WGS")
     self.remove_unwanted_samples()
     index.adapt_indexes(
         samples=self.lims_samples,
         control_software_version=self.run_parameters.
         control_software_version,
         reagent_kit_version=self.run_parameters.reagent_kit_version,
         expected_index_length=self.run_parameters.index_length,
     )
     sample_sheet: str = self.convert_to_sample_sheet()
     LOG.info("Validating sample sheet")
     get_sample_sheet(
         sample_sheet=sample_sheet,
         sheet_type="S2",
         bcl_converter=self.bcl_converter,
     )
     LOG.info("Sample sheet looks fine")
     return sample_sheet
def test_validate_s2_bcl2fastq_sample_sheet_duplicate_same_lane():
    # GIVEN a NovaSeq S2 sample sheet with same sample duplicated in same lane
    sheet_type = "S2"
    bcl_converter = "bcl2fastq"

    sample_sheet_string = (
        "[Data]\n"
        "FCID,Lane,SampleID,SampleRef,index,index2,SampleName,Control,Recipe,Operator,Project\n"
        "HWHMWDMXX,1,ACC7628A68,hg19,ATTCCACACT,TGGTCTTGTT,814206,N,R1,script,814206\n"
        "HWHMWDMXX,1,ACC7628A1,hg19,AGTTAGCTGG,GATGAGAATG,814206,N,R1,script,814206\n"
        "HWHMWDMXX,1,ACC7628A1,hg19,GAGAGCTAAC,CAATACTTGC,814206,N,R1,script,814206\n"
    )

    # WHEN validating the sampVle sheet
    with pytest.raises(SampleSheetError):
        # THEN assert that a sample sheet error is raised
        get_sample_sheet(
            sample_sheet=sample_sheet_string, sheet_type=sheet_type, bcl_converter=bcl_converter
        )
def test_missing_samples():

    # GIVEN a NovaSeq S2 sample sheet with a missing samples
    sheet_type = "S2"
    bcl_converter = "dragen"

    sample_sheet_string = (
        "[Data]\n"
        "FCID,Lane,Sample_ID,SampleRef,index,index2,SampleName,Control,Recipe,Operator,"
        "Sample_Project\n"
    )
    # WHEN validating the sample sheet
    with pytest.raises(SampleSheetError):
        # THEN assert that a sample sheet error is raised
        get_sample_sheet(
            sample_sheet=sample_sheet_string,
            sheet_type=sheet_type,
            bcl_converter=bcl_converter,
        )
def test_missing_header():

    # GIVEN a NovaSeq S2 sample sheet with a missing header
    sheet_type = "S2"
    bcl_converter = "dragen"

    sample_sheet_string = (
        "[Data]\n"
        "HWHMWDMXX,1,ACC7628A68,hg19,ATTCCACACT,TGGTCTTGTT,814206,N,R1,script,814206\n"
        "HWHMWDMXX,1,ACC7628A1,hg19,AGTTAGCTGG,GATGAGAATG,814206,N,R1,script,814206\n"
        "HWHMWDMXX,2,ACC7628A1,hg19,GAGAGCTAAC,CAATACTTGC,814206,N,R1,script,814206\n"
    )
    # WHEN validating the sample sheet
    with pytest.raises(SampleSheetError):
        # THEN assert that a sample sheet error is raised
        get_sample_sheet(
            sample_sheet=sample_sheet_string,
            sheet_type=sheet_type,
            bcl_converter=bcl_converter,
        )
Ejemplo n.º 5
0
def test_convert_to_bcl2fastq_sheet(
        novaseq_bcl2fastq_sample_sheet_object: SampleSheetCreator,
        project_dir: Path):
    # GIVEN a sample sheet object populated with samples
    assert novaseq_bcl2fastq_sample_sheet_object.lims_samples

    # WHEN converting to a sample sheet
    sample_sheet: str = novaseq_bcl2fastq_sample_sheet_object.construct_sample_sheet(
    )

    # THEN assert a correctly formatted sample sheet was created
    sample_sheet_object: SampleSheet = get_sample_sheet(
        sample_sheet=sample_sheet,
        sheet_type="S4",
        bcl_converter=novaseq_bcl2fastq_sample_sheet_object.bcl_converter,
    )
    assert sample_sheet_object.samples
def test_validate_s2_bcl2fastq_sample_sheet_str():
    # GIVEN a NovaSeq S2 sample sheet
    sheet_type = "S2"
    bcl_converter = "bcl2fastq"

    sample_sheet_string = (
        "[Data]\n"
        "FCID,Lane,SampleID,SampleRef,index,index2,SampleName,Control,Recipe,Operator,Project\n"
        "HWHMWDMXX,1,ACC7628A68,hg19,ATTCCACACT,TGGTCTTGTT,814206,N,R1,script,814206\n"
        "HWHMWDMXX,1,ACC7628A1,hg19,AGTTAGCTGG,GATGAGAATG,814206,N,R1,script,814206"
    )

    # WHEN validating the sample sheet
    sheet: SampleSheet = get_sample_sheet(
        sample_sheet=sample_sheet_string, sheet_type=sheet_type, bcl_converter=bcl_converter
    )
    # THEN assert that the sample sheet has the correct type
    assert sheet.type == sheet_type
def test_validate_s2_bcl2fastq_sample_sheet_duplicate_different_lanes():
    # GIVEN a NovaSeq S2 sample sheet with same sample duplicated in different lanes
    sheet_type = "S2"
    bcl_converter = "bcl2fastq"

    sample_sheet_string = (
        "[Data]\n"
        "FCID,Lane,SampleID,SampleRef,index,index2,SampleName,Control,Recipe,Operator,Project\n"
        "HWHMWDMXX,1,ACC7628A68,hg19,ATTCCACACT,TGGTCTTGTT,814206,N,R1,script,814206\n"
        "HWHMWDMXX,1,ACC7628A1,hg19,AGTTAGCTGG,GATGAGAATG,814206,N,R1,script,814206\n"
        "HWHMWDMXX,2,ACC7628A1,hg19,GAGAGCTAAC,CAATACTTGC,814206,N,R1,script,814206\n"
    )

    # WHEN validating the sample sheet
    sample_sheet: SampleSheet = get_sample_sheet(
        sample_sheet=sample_sheet_string, sheet_type=sheet_type, bcl_converter=bcl_converter
    )

    # THEN assert that a sample sheet is returned with samples in it
    assert sample_sheet.samples