generated from spawnia/php-package-template
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Support creating Lightcycler Sample Sheets for Absolute Quantification #55
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
spawnia
merged 19 commits into
master
from
lightcycler-sample-sheets-for-absolute-quantification
Aug 5, 2025
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
9794479
feat: Support creating Lightcycler Sample Sheets for Absolute Quantif…
ee12c53
refactor: Update skipped Rector rules:
bf1b1a6
feat: Introduce LIGHTCYCLER_COLOR_PREFIX for consistent hex color for…
dfaae77
Apply php-cs-fixer changes
simbig d1e412c
feat: Update AbsoluteQuantificationSample to use nullable integer for…
881f591
Merge remote-tracking branch 'origin/lightcycler-sample-sheets-for-ab…
aec73d5
refactor: Refactor concentration formatting with no sprintf
d65525e
refactor: Refactor concentration formatting with number_format
7ac393f
test: Add attribute for data provider in AbsoluteQuantificationSample…
00eac05
composer update in make setup
spawnia 7e6259a
long form cli
spawnia 7264ab1
link PR
spawnia b09c588
Set php-cs-fixer cache in config file
spawnia adb94bf
feat: Add replication mapping in AbsoluteQuantificationSample
d6a507b
Merge remote-tracking branch 'origin/lightcycler-sample-sheets-for-ab…
ef233f9
Leverage CSVArray
spawnia da32d17
Simplify with iterable, fix test
spawnia 6a57c2e
Unify Windows newline
spawnia a0b083d
Fix PHPStan
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
57 changes: 57 additions & 0 deletions
57
src/LightcyclerSampleSheet/AbsoluteQuantificationSample.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,57 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\LightcyclerSampleSheet; | ||
|
||
use MLL\Utils\Microplate\Coordinates; | ||
use MLL\Utils\Microplate\CoordinateSystem12x8; | ||
|
||
class AbsoluteQuantificationSample | ||
{ | ||
public string $sampleName; | ||
|
||
public string $filterCombination; | ||
|
||
public string $hexColor; | ||
|
||
public string $sampleType; | ||
|
||
public string $concentration; | ||
|
||
/** @var Coordinates<CoordinateSystem12x8>|null */ | ||
public ?Coordinates $replicationOf; | ||
|
||
/** @param Coordinates<CoordinateSystem12x8>|null $replicationOf */ | ||
public function __construct( | ||
string $sampleName, | ||
string $filterCombination, | ||
string $hexColor, | ||
string $sampleType, | ||
string $concentration, | ||
?Coordinates $replicationOf = null | ||
) { | ||
$this->sampleName = $sampleName; | ||
$this->filterCombination = $filterCombination; | ||
$this->hexColor = $hexColor; | ||
$this->sampleType = $sampleType; | ||
$this->concentration = $concentration; | ||
$this->replicationOf = $replicationOf; | ||
} | ||
|
||
/** @return list<string> */ | ||
public function toSerializableArray(string $coordinatesString): array | ||
{ | ||
$replicationOf = $this->replicationOf instanceof Coordinates | ||
? "\"{$this->replicationOf->toString()}\"" | ||
: '""'; | ||
|
||
return [ | ||
Coordinates::fromString($coordinatesString, new CoordinateSystem12x8())->toString(), | ||
"\"{$this->sampleName}\"", | ||
$replicationOf, | ||
$this->filterCombination, | ||
"$00{$this->hexColor}", | ||
"\"{$this->sampleType}\"", | ||
"\"{$this->concentration}\"", | ||
]; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/LightcyclerSampleSheet/AbsoluteQuantificationSheet.php
spawnia marked this conversation as resolved.
Show resolved
Hide resolved
|
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,30 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\LightcyclerSampleSheet; | ||
|
||
use Illuminate\Support\Collection; | ||
use MLL\Utils\StringUtil; | ||
|
||
class AbsoluteQuantificationSheet | ||
{ | ||
public const HEADER_COLUMNS = [ | ||
'"General:Pos"', | ||
'"General:Sample Name"', | ||
'"General:Repl. Of"', | ||
'"General:Filt. Comb."', | ||
'"Sample Preferences:Color"', | ||
'"Abs Quant:Sample Type"', | ||
'"Abs Quant:Concentration"', | ||
]; | ||
|
||
/** @param Collection<string, AbsoluteQuantificationSample> $samples */ | ||
public function generate(Collection $samples): string | ||
{ | ||
return $samples | ||
->map(fn (AbsoluteQuantificationSample $well, string $coordinateFromKey): array => $well->toSerializableArray($coordinateFromKey)) | ||
->prepend(self::HEADER_COLUMNS) | ||
->map(fn (array $row): string => implode(StringUtil::TAB, $row)) | ||
->implode(StringUtil::WINDOWS_NEW_LINE) | ||
. StringUtil::WINDOWS_NEW_LINE; | ||
} | ||
} |
simbig marked this conversation as resolved.
Show resolved
Hide resolved
|
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
52 changes: 52 additions & 0 deletions
52
tests/LightcyclerSampleSheet/AbsoluteQuantificationSheetTest.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,52 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace MLL\Utils\Tests\LightcyclerSampleSheet; | ||
|
||
use Illuminate\Support\Collection; | ||
use MLL\Utils\LightcyclerSampleSheet\AbsoluteQuantificationSample; | ||
use MLL\Utils\LightcyclerSampleSheet\AbsoluteQuantificationSheet; | ||
use MLL\Utils\Microplate\Coordinates; | ||
use MLL\Utils\Microplate\CoordinateSystem12x8; | ||
use MLL\Utils\StringUtil; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class AbsoluteQuantificationSheetTest extends TestCase | ||
{ | ||
public function testGenerateWithFakeData(): void | ||
{ | ||
$coordinateSystem = new CoordinateSystem12x8(); | ||
|
||
$samples = Collection::make([ | ||
'A1' => new AbsoluteQuantificationSample('Standard_1', '485-520', 'FF0000', 'Standard', '1000.0', null), | ||
'B1' => new AbsoluteQuantificationSample('Standard_1', '485-520', 'FF0001', 'Standard', '1000.0', Coordinates::fromString('A1', $coordinateSystem)), | ||
'C1' => new AbsoluteQuantificationSample('Standard_2', '485-520', '00FF00', 'Standard', '100.0', null), | ||
'D1' => new AbsoluteQuantificationSample('Standard_2', '485-520', '00FF01', 'Standard', '100.0', Coordinates::fromString('C1', $coordinateSystem)), | ||
'E1' => new AbsoluteQuantificationSample('Sample_001', '485-520', '0000FF', 'Unknown', '', null), | ||
'F1' => new AbsoluteQuantificationSample('Sample_001', '485-520', '0000FE', 'Unknown', '', Coordinates::fromString('E1', $coordinateSystem)), | ||
'G1' => new AbsoluteQuantificationSample('Sample_002', '485-520', 'FFFF00', 'Unknown', '', null), | ||
'H1' => new AbsoluteQuantificationSample('Sample_002', '485-520', 'FFFF01', 'Unknown', '', Coordinates::fromString('G1', $coordinateSystem)), | ||
'A2' => new AbsoluteQuantificationSample('NTC', '485-520', '000000', 'Negative Control', '', null), | ||
'B2' => new AbsoluteQuantificationSample('NTC', '485-520', '000001', 'Negative Control', '', Coordinates::fromString('A2', $coordinateSystem)), | ||
]); | ||
|
||
$sheet = new AbsoluteQuantificationSheet(); | ||
$result = $sheet->generate($samples); | ||
|
||
$expected = <<<EOT | ||
"General:Pos"\t"General:Sample Name"\t"General:Repl. Of"\t"General:Filt. Comb."\t"Sample Preferences:Color"\t"Abs Quant:Sample Type"\t"Abs Quant:Concentration" | ||
A1\t"Standard_1"\t""\t485-520\t$00FF0000\t"Standard"\t"1000.0" | ||
B1\t"Standard_1"\t"A1"\t485-520\t$00FF0001\t"Standard"\t"1000.0" | ||
C1\t"Standard_2"\t""\t485-520\t$0000FF00\t"Standard"\t"100.0" | ||
D1\t"Standard_2"\t"C1"\t485-520\t$0000FF01\t"Standard"\t"100.0" | ||
E1\t"Sample_001"\t""\t485-520\t$000000FF\t"Unknown"\t"" | ||
F1\t"Sample_001"\t"E1"\t485-520\t$000000FE\t"Unknown"\t"" | ||
G1\t"Sample_002"\t""\t485-520\t$00FFFF00\t"Unknown"\t"" | ||
H1\t"Sample_002"\t"G1"\t485-520\t$00FFFF01\t"Unknown"\t"" | ||
A2\t"NTC"\t""\t485-520\t$00000000\t"Negative Control"\t"" | ||
B2\t"NTC"\t"A2"\t485-520\t$00000001\t"Negative Control"\t"" | ||
EOT; | ||
|
||
self::assertSame(StringUtil::normalizeLineEndings($expected), $result); | ||
} | ||
} |
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
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.