generated from spawnia/php-package-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Illumina sample sheet v2 #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
c55368a
feature: Add Support Illumina NovaSeq Sample Sheets
b8fdb07
move to v1 and v2
3a95c00
header and convertSectionToString
b7965e3
ReadsSection
752cfce
move tests
d2053e9
simplify
465f5d1
MiSeq header
57c6d87
flexible data section
44277ca
validate index
90765ac
Merge branch 'refs/heads/master' into illumina-sample-sheet
de8f591
Update phpunit cli
spawnia 5afda9f
DataProvider-Attribute
f5144a6
ignore v1 sample sheet
3896dfa
fluent
04c7e9e
no cloud
4b9786f
bcl convert
71f0da2
Bcl Sample
e805d91
Apply php-cs-fixer changes
simbig 79538dd
update CHANGELOG.md
57dfe21
Merge remote-tracking branch 'origin/illumina-sample-sheet-v2' into i…
adc6dfe
keep dataProvider
dfa2636
keep dataProvider pt2
7c974dc
keep dataProvider pt3
3852ff6
Apply suggestions from code review
simbig bd5e48a
fix code
6cb4331
fixes from review
58672d7
protected
56a580c
remove setter
27b6b66
add comment to sample_ID property
fbb9d6e
Apply php-cs-fixer changes
simbig 3c2c3b4
PHPDoc
spawnia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\IlluminaSampleSheet; | ||
|
||
class IlluminaSampleSheetException extends \Exception {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\IlluminaSampleSheet; | ||
|
||
abstract class SampleSheet | ||
{ | ||
/** @var array<Section> */ | ||
protected array $sections = []; | ||
|
||
public function addSection(Section $section): void | ||
{ | ||
$this->sections[] = $section; | ||
} | ||
|
||
public function toString(): string | ||
{ | ||
$sectionStrings = array_map( | ||
fn (Section $section): string => $section->convertSectionToString(), | ||
$this->sections | ||
); | ||
|
||
return implode("\n", $sectionStrings); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\IlluminaSampleSheet; | ||
|
||
interface Section | ||
{ | ||
public function convertSectionToString(): string; | ||
} |
28 changes: 28 additions & 0 deletions
28
src/IlluminaSampleSheet/V2/BclConvert/BclConvertSection.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\IlluminaSampleSheet\V2\BclConvert; | ||
|
||
use MLL\Utils\IlluminaSampleSheet\Section; | ||
|
||
class BclConvertSection implements Section | ||
{ | ||
protected SettingsSection $settingsSection; | ||
|
||
protected DataSection $dataSection; | ||
|
||
public function __construct(SettingsSection $settingsSection, DataSection $dataSection) | ||
{ | ||
$this->settingsSection = $settingsSection; | ||
$this->dataSection = $dataSection; | ||
} | ||
|
||
public function convertSectionToString(): string | ||
{ | ||
$bclConvertLines = [ | ||
$this->settingsSection->convertSectionToString(), | ||
$this->dataSection->convertSectionToString(), | ||
]; | ||
|
||
return implode("\n", $bclConvertLines); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\IlluminaSampleSheet\V2\BclConvert; | ||
|
||
class BclSample | ||
{ | ||
public int $lane; | ||
|
||
/** Not using camelCase because the property names of this class must match the CSV file. */ | ||
public string $sample_ID; | ||
|
||
public string $index; | ||
|
||
public ?string $index2 = null; | ||
|
||
public ?string $overrideCycles = null; | ||
|
||
public ?string $adapterRead1 = null; | ||
|
||
public ?string $adapterRead2 = null; | ||
|
||
public ?string $barcodeMismatchesIndex1 = null; | ||
|
||
public ?string $barcodeMismatchesIndex2 = null; | ||
|
||
public function __construct( | ||
int $lane, | ||
string $sample_ID, | ||
string $index | ||
) { | ||
$this->lane = $lane; | ||
$this->sample_ID = $sample_ID; | ||
$this->index = $index; | ||
} | ||
|
||
/** @return array<int|string> */ | ||
public function toArray(): array | ||
{ | ||
return array_filter([ | ||
$this->lane, | ||
$this->sample_ID, | ||
$this->index, | ||
$this->index2, | ||
$this->overrideCycles, | ||
$this->adapterRead1, | ||
$this->adapterRead2, | ||
$this->barcodeMismatchesIndex1, | ||
$this->barcodeMismatchesIndex2, | ||
]); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\IlluminaSampleSheet\V2\BclConvert; | ||
|
||
use MLL\Utils\IlluminaSampleSheet\Section; | ||
|
||
class DataSection implements Section | ||
{ | ||
/** @var array<BclSample> */ | ||
protected array $dataRows = []; | ||
|
||
public function addSample(BclSample $bclSample): void | ||
{ | ||
$this->dataRows[] = $bclSample; | ||
} | ||
|
||
public function convertSectionToString(): string | ||
{ | ||
/** @var array<string> $samplePropertiesOfFirstSample */ | ||
$samplePropertiesOfFirstSample = array_keys(get_object_vars($this->dataRows[0])); | ||
foreach ($this->dataRows as $sample) { | ||
$actualProperties = array_keys(get_object_vars($sample)); | ||
if ($samplePropertiesOfFirstSample !== $actualProperties) { | ||
throw new \Exception('All samples must have the same properties. Expected: ' . \Safe\json_encode($samplePropertiesOfFirstSample) . ', Actual: ' . \Safe\json_encode($actualProperties)); | ||
} | ||
} | ||
|
||
$bclConvertDataHeaderLines = $this->generateDataHeaderByProperties($samplePropertiesOfFirstSample); | ||
|
||
$bclConvertDataLines = [ | ||
simbig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
'[BCLConvert_Data]', | ||
$bclConvertDataHeaderLines, | ||
]; | ||
|
||
foreach ($this->dataRows as $dataRow) { | ||
$bclConvertDataLines[] = implode(',', $dataRow->toArray()); | ||
} | ||
|
||
return implode("\n", $bclConvertDataLines) . "\n"; | ||
} | ||
|
||
/** @param array<string> $samplePropertiesOfFirstSample */ | ||
protected function generateDataHeaderByProperties(array $samplePropertiesOfFirstSample): string | ||
{ | ||
$samplePropertiesOfFirstSample = array_filter($samplePropertiesOfFirstSample, fn (string $value) // @phpstan-ignore-next-line Variable property access on a non-object required here | ||
=> $this->dataRows[0]->$value !== null); | ||
|
||
$samplePropertiesOfFirstSample = array_map(fn (string $value) => ucfirst($value), $samplePropertiesOfFirstSample); | ||
|
||
return implode(',', $samplePropertiesOfFirstSample); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\IlluminaSampleSheet\V2\BclConvert; | ||
|
||
use MLL\Utils\IlluminaSampleSheet\Section; | ||
use MLL\Utils\IlluminaSampleSheet\V2\Enums\FastQCompressionFormat; | ||
|
||
class SettingsSection implements Section | ||
{ | ||
public string $softwareVersion; | ||
|
||
public FastQCompressionFormat $fastqCompressionFormat; | ||
|
||
public ?bool $trimUMI = null; | ||
|
||
public function __construct( | ||
string $softwareVersion, | ||
FastQCompressionFormat $fastqCompressionFormat | ||
) { | ||
$this->softwareVersion = $softwareVersion; | ||
$this->fastqCompressionFormat = $fastqCompressionFormat; | ||
} | ||
|
||
public function convertSectionToString(): string | ||
{ | ||
$bclConvertSettingsLines = [ | ||
'[BCLConvert_Settings]', | ||
"SoftwareVersion,{$this->softwareVersion}", | ||
"FastqCompressionFormat,{$this->fastqCompressionFormat->value}", | ||
]; | ||
|
||
if (! is_null($this->trimUMI)) { | ||
$trimUMIAsString = $this->trimUMI | ||
? '1' | ||
: '0'; | ||
|
||
$bclConvertSettingsLines[] = "TrimUMI,{$trimUMIAsString}"; | ||
} | ||
|
||
return implode("\n", $bclConvertSettingsLines) . "\n"; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/IlluminaSampleSheet/V2/Enums/FastQCompressionFormat.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\IlluminaSampleSheet\V2\Enums; | ||
|
||
class FastQCompressionFormat | ||
{ | ||
public const GZIP = 'gzip'; | ||
public const DRAGEN = 'dragen'; | ||
|
||
public string $value; | ||
|
||
public function __construct(string $value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
public static function GZIP(): self | ||
{ | ||
return new self(self::GZIP); | ||
} | ||
|
||
public static function DRAGEN(): self | ||
{ | ||
return new self(self::DRAGEN); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\IlluminaSampleSheet\V2; | ||
|
||
use MLL\Utils\IlluminaSampleSheet\Section; | ||
|
||
class HeaderSection implements Section | ||
{ | ||
protected const FILE_FORMAT_VERSION = '2'; | ||
|
||
protected string $fileFormatVersion = self::FILE_FORMAT_VERSION; | ||
|
||
public string $runName; | ||
|
||
public ?string $runDescription = null; | ||
|
||
public ?string $instrumentType = null; | ||
|
||
public ?string $instrumentPlatform = null; | ||
|
||
/** @var array<string, string> */ | ||
protected array $customParams = []; | ||
|
||
public function __construct(string $runName) | ||
{ | ||
$this->runName = $runName; | ||
} | ||
|
||
public function setCustomParam(string $paramName, string $paramValue): void | ||
{ | ||
$this->customParams['Custom_' . $paramName] = $paramValue; | ||
} | ||
|
||
public function convertSectionToString(): string | ||
{ | ||
$headerLines = [ | ||
'[Header]', | ||
"FileFormatVersion,{$this->fileFormatVersion}", | ||
"RunName,{$this->runName}", | ||
]; | ||
if (! is_null($this->runDescription)) { | ||
$headerLines[] = "RunDescription,{$this->runDescription}"; | ||
} | ||
if (! is_null($this->instrumentType)) { | ||
$headerLines[] = "InstrumentType,{$this->instrumentType}"; | ||
} | ||
if (! is_null($this->instrumentPlatform)) { | ||
$headerLines[] = "InstrumentPlatform,{$this->instrumentPlatform}"; | ||
} | ||
foreach ($this->customParams as $paramName => $paramValue) { | ||
$headerLines[] = "{$paramName},{$paramValue}"; | ||
} | ||
|
||
return implode("\n", $headerLines) . "\n"; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\IlluminaSampleSheet\V2; | ||
|
||
use MLL\Utils\IlluminaSampleSheet\SampleSheet; | ||
use MLL\Utils\IlluminaSampleSheet\V2\BclConvert\BclConvertSection; | ||
|
||
class NovaSeqXSampleSheet extends SampleSheet | ||
{ | ||
public function __construct( | ||
HeaderSection $header, | ||
ReadsSection $reads, | ||
?BclConvertSection $bclConvertSection | ||
) { | ||
$this->addSection($header); | ||
$this->addSection($reads); | ||
if (! is_null($bclConvertSection)) { | ||
$this->addSection($bclConvertSection); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.