Skip to main content

V2 SampleSheet Maker

Build and Deploy PyPI version

Generate an Illumina SampleSheet CSV from JSON.

Supported Sections

Sections currently supported:

  • Header
  • Reads
  • BCLConvert_Settings
  • BCLConvert_Data

Installation

Installation from pypi

pip install v2-samplesheet-maker

Alternatively one may use the docker container ghcr.io/umccr/v2-samplesheet-maker:latest

Usage

Usage:
v2-samplesheet-maker <input-json> <output-csv>

Use - for input-json parameter to parse json from stdin,
Use - for output-json parameter to parse output samplesheet csv to stdout.

Examples

See examples/ for more info

Input JSON

Click to expand!
{
  "header": {
    "file_format_version": 2,
    "run_name": "my-illumina-sequencing-run",
    "run_description": "A test run",
    "instrument_platform": "NovaSeq 6000",
    "instrument_type": "NovaSeq"
  },
  "reads": {
    "read_1_cycles": 151,
    "read_2_cycles": 151,
    "index_1_cycles": 10,
    "index_2_cycles": 10
  },
  "bclconvert_settings": {
    "adapter_behavior": "trim",
    "adapter_read_1": null,
    "adapter_read_2": null,
    "adapter_stringency": null,
    "barcode_mismatches_index_1": 1,
    "barcode_mismatches_index_2": 1,
    "minimum_trimmed_read_length": null,
    "minimum_adapter_overlap": 2,
    "mask_short_reads": null,
    "override_cycles": "Y151;Y10;Y8N2;Y151",
    "trim_umi": null,
    "create_fastq_for_index_reads": false,
    "no_lane_splitting": false,
    "fastq_compression_format": "gzip",
    "find_adapters_with_indels": null,
    "independent_index_collision_check": null
  },
  "bclconvert_data": [
    {
      "sample_id": "MyFirstSample",
      "lane": 1,
      "index": "AAAAAAAAAA",
      "index2": "CCCCCCCC",
      "sample_project": "SampleProject",
      "sample_name": null
    },
    {
      "sample_id": "MySecondSample",
      "lane": 1,
      "index": "GGGGGGGGGG",
      "index2": "TTTTTTTT",
      "sample_project": "SampleProject",
      "sample_name": null
    }
  ]
}

Output CSV

Click to expand!
[Header]
FileFormatVersion,2
RunName,my-illumina-sequencing-run
RunDescription,A test run
InstrumentPlatform,NovaSeq 6000
InstrumentType,NovaSeq

[Reads]
Read1Cycles,151
Read2Cycles,151
Index1Cycles,10
Index2Cycles,10

[BCLConvert_Settings]
AdapterBehavior,trim
BarcodeMismatchesIndex1,1
BarcodeMismatchesIndex2,1
MinimumAdapterOverlap,2
OverrideCycles,Y151;Y10;Y8N2;Y151
CreateFastqForIndexReads,False
NoLaneSplitting,False
FastqCompressionFormat,gzip

[BCLConvert_Data]
Lane,Sample_ID,index,index2,Sample_Project
1,MyFirstSample,AAAAAAAAAA,CCCCCCCC,SampleProject
1,MySecondSample,GGGGGGGGGG,TTTTTTTT,SampleProject

Testing your outputs

The v2-samplesheet-maker will validate that your parameters are the correct type, the correct name AND within the appropriate range. It will NOT however determine if your settings are appropriate or compatible with a BCLConvert run, i.e it will NOT ensure that your indexes have an appropriate hamming distance.

If you wish to validate your output samplesheet with BCLConvert, you can use the following script -

scripts/build-samplesheet-and-validate-with-bcl-convert.sh <input-json> [docker-image]. This will convert the input json to csv and then run the docker container bclconvert against your samplesheet.

You will need both jq and docker installed for this to work.

Additional Usage

Parsing a SampleSheet CSV to JSON

We also have created a parser between the csv and json, with the following usage syntax

Input SampleSheet CSV

Click to expand!
[Header]
FileFormatVersion,2
RunName,my-illumina-sequencing-run
RunDescription,A test run
InstrumentPlatform,NovaSeq 6000
InstrumentType,NovaSeq

[Reads]
Read1Cycles,151
Read2Cycles,151
Index1Cycles,10
Index2Cycles,10

[BCLConvert_Settings]
AdapterBehavior,trim
BarcodeMismatchesIndex1,1
BarcodeMismatchesIndex2,1
MinimumAdapterOverlap,2
OverrideCycles,Y151;Y10;Y8N2;Y151
CreateFastqForIndexReads,False
NoLaneSplitting,False
FastqCompressionFormat,gzip

[BCLConvert_Data]
Lane,Sample_ID,index,index2,Sample_Project
1,MyFirstSample,AAAAAAAAAA,CCCCCCCC,SampleProject
1,MySecondSample,GGGGGGGGGG,TTTTTTTT,SampleProject
# Initialise new index variable
NEW_I7_INDEX="TTTTTTTTTT"
SAMPLE_ID="MySecondSample"

# Convert the SampleSheet to JSON
# Update the index for the sample "MySecondSample" in the bclconvert_data section
# Write out the new samplesheet to csv
v2-samplesheet-to-json SampleSheet.csv - | \
jq --raw-output \
  --arg sample_id "${SAMPLE_ID}" \
  --arg replacement_index "${NEW_I7_INDEX}" \
  '
    .bclconvert_data=( 
      .bclconvert_data |
      map(
        if .sample_id == $sample_id then
          .index = $replacement_index
        else
          .
        end
      )
    )
  ' | \
v2-samplesheet-maker - SampleSheet.updated_index.csv 

Gives us the following samplesheet as an output

[Header]
FileFormatVersion,2
RunName,my-illumina-sequencing-run
RunDescription,A test run
InstrumentPlatform,NovaSeq 6000
InstrumentType,NovaSeq

[Reads]
Read1Cycles,151
Read2Cycles,151
Index1Cycles,10
Index2Cycles,10

[BCLConvert_Settings]
AdapterBehavior,trim
BarcodeMismatchesIndex1,1
BarcodeMismatchesIndex2,1
MinimumAdapterOverlap,2
OverrideCycles,Y151;Y10;Y8N2;Y151
CreateFastqForIndexReads,False
NoLaneSplitting,False
FastqCompressionFormat,gzip

[BCLConvert_Data]
Lane,Sample_ID,index,index2,Sample_Project
1,MyFirstSample,AAAAAAAAAA,CCCCCCCC,SampleProject
1,MySecondSample,TTTTTTTTTT,TTTTTTTT,SampleProject

If we run a diff on our original and updated samplesheet, we can see that the index for "MySecondSample" has been updated.

diff SampleSheet.csv SampleSheet.updated_index.csv

Yields

27c27
< 1,MySecondSample,GGGGGGGGGG,TTTTTTTT,SampleProject
---
> 1,MySecondSample,TTTTTTTTTT,TTTTTTTT,SampleProject

Manipulating a samplesheet by parsing through JSON

For this component, you will need some basic knowledge of the jq command line tool.

In this example we are given a standard samplesheet but want to edit the adapters for one of the samples.

Whilst we could do this with grep, sed or awk, it's a little hacky, instead we can

  1. Parse the samplesheet to json to stdout
  2. Use jq to update the samplesheet
  3. Write out the updated samplesheet to csv
v2-samplesheet-to-json 

Contributing

Is there a missing section you'd like to see?

You can generate your own sections by

  1. Forking this repository.
  2. Adding the section pydantic model to the section models module
  3. Extending the SampleSheel pydantic model in the samplesheet models module
  4. Generating a class for your section in the section class module
  5. Extending the SampleSheet class to write out your section in the samplesheet class module
  6. Add a test for your section in the test_sections module
  7. Generating a PR back to this repository! ( Please squash your commits :) )

Release Cycles

We try and update this repository for every new Dragen Release (which coincides with a BCLConvert release) and tag accordingly.

Metadata

Release files for v2-samplesheet-maker 4.2.4.post20240220125103

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for v2-samplesheet-maker 4.2.4.post20240220125103
File Size Uploaded Provenance Actions
v2_samplesheet_maker-4.2.4.post20240220125103.tar.gz 26.0 kB Without provenance Details for v2_samplesheet_maker-4.2.4.post20240220125103.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for v2-samplesheet-maker 4.2.4.post20240220125103
File Interpreter ABI Platform Actions
v2_samplesheet_maker-4.2.4.post20240220125103-py3-none-any.whl Python 3 none any Details for v2_samplesheet_maker-4.2.4.post20240220125103-py3-none-any.whl

Total release size: 59.5 kB

Release files / v2_samplesheet_maker-4.2.4.post20240220125103.tar.gz

Download URL v2_samplesheet_maker-4.2.4.post20240220125103.tar.gz
Size 26.0 kB
Tags Source
SHA-256 checksum
How to use checksums
201666bde6bc3e37c529a3ca72ccfa8c926ab4796bbb9b097252345f66b00ca8
BLAKE2b-256 checksum
How to use checksums
b3d9c85fbfd8932d82e5bf8e1c3d0d65ca62abbc2a30e85aff26c1b16ff93d5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.8

Release files / v2_samplesheet_maker-4.2.4.post20240220125103-py3-none-any.whl

Download URL v2_samplesheet_maker-4.2.4.post20240220125103-py3-none-any.whl
Size 33.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c14c6f76ceeca7ce18e02257f3faf762500a0d3e3e39073f4912e2707955443
BLAKE2b-256 checksum
How to use checksums
10a691319c9123b00743cdb7fd7c0e278ca482d7145555343b70b12f10b15c6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.8

Security for v2-samplesheet-maker 4.2.4.post20240220125103

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page