Skip to content

Commit

Permalink
MLL
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Apr 23, 2024
1 parent 8f19b1a commit 88525a4
Show file tree
Hide file tree
Showing 12 changed files with 343 additions and 45 deletions.
11 changes: 0 additions & 11 deletions src/FluidXPlate/InvalidRackIdException.php

This file was deleted.

61 changes: 61 additions & 0 deletions src/Tecan/CustomCommands/MLLReagentDistribution.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php declare(strict_types=1);

namespace MLL\Utils\Tecan\CustomCommands;

use MLL\Utils\Tecan\BasicCommands\Command;
use MLL\Utils\Tecan\BasicCommands\ReagentDistribution;
use MLL\Utils\Tecan\LiquidClass\LiquidClass;
use MLL\Utils\Tecan\ReagentDistribution\ReagentDistributionDirection;

final class MLLReagentDistribution extends Command
{
public const NUMBER_OF_DITI_REUSES = 6;
public const NUMBER_OF_MULTI_DISP = 1;

private AspirateParameters $source;

private DispenseParameters $target;

private float $volume;

private LiquidClass $liquidClass;

public function __construct(
AspirateParameters $source,
DispenseParameters $target,
float $dispenseVolume,
LiquidClass $liquidClass
) {
$this->source = $source;
$this->target = $target;
$this->volume = $dispenseVolume;
$this->liquidClass = $liquidClass;
}

public function toString(): string
{
$reagentDistribution = new ReagentDistribution(
$this->source->formatToAspirateAndDispenseParameters(),
$this->target->formatToAspirateAndDispenseParameters(),
$this->volume,
$this->liquidClass,
self::NUMBER_OF_DITI_REUSES,
self::NUMBER_OF_MULTI_DISP,
ReagentDistributionDirection::LEFT_TO_RIGHT(),
$this->excludedWells(),
);

return $reagentDistribution->toString();
}

/** @return array<int, int> */
private function excludedWells(): array
{
$min = min($this->target->dispensePositions);
$max = max($this->target->dispensePositions);

$allWellsFromStartToEnd = range($min, $max);

return array_diff($allWellsFromStartToEnd, $this->target->dispensePositions);
}
}
49 changes: 49 additions & 0 deletions src/Tecan/LiquidClass/MLLLiquidClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php declare(strict_types=1);

namespace MLL\Utils\Tecan\LiquidClass;

class MLLLiquidClass implements LiquidClass
{
public const DNA_DILUTION = 'DNA_Dilution';
public const DNA_DILUTION_WATER = 'DNA_Dilution_Water';
public const TRANSFER_PCR_PRODUKT = 'Transfer_PCR_Produkt';
public const TRANSFER_MASTERMIX_MP = 'Transfer_Mastermix_MP';
public const TRANSFER_TEMPLATE = 'Transfer_Template'; // DNA-templates and BUFFER!

public string $value;

public function __construct(string $value)
{
$this->value = $value;
}

public static function DNA_DILUTION(): self

Check failure on line 20 in src/Tecan/LiquidClass/MLLLiquidClass.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

Class MLL\Utils\Tecan\LiquidClass\MllLiquidClass referenced with incorrect case: MLL\Utils\Tecan\LiquidClass\MLLLiquidClass.
{
return new self(self::DNA_DILUTION);
}

public static function DNA_DILUTION_WATER(): self

Check failure on line 25 in src/Tecan/LiquidClass/MLLLiquidClass.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

Class MLL\Utils\Tecan\LiquidClass\MllLiquidClass referenced with incorrect case: MLL\Utils\Tecan\LiquidClass\MLLLiquidClass.
{
return new self(self::DNA_DILUTION_WATER);
}

public static function TRANSFER_PCR_PRODUKT(): self

Check failure on line 30 in src/Tecan/LiquidClass/MLLLiquidClass.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

Class MLL\Utils\Tecan\LiquidClass\MllLiquidClass referenced with incorrect case: MLL\Utils\Tecan\LiquidClass\MLLLiquidClass.
{
return new self(self::TRANSFER_PCR_PRODUKT);
}

public static function TRANSFER_MASTERMIX_MP(): self

Check failure on line 35 in src/Tecan/LiquidClass/MLLLiquidClass.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

Class MLL\Utils\Tecan\LiquidClass\MllLiquidClass referenced with incorrect case: MLL\Utils\Tecan\LiquidClass\MLLLiquidClass.
{
return new self(self::TRANSFER_MASTERMIX_MP);
}

public static function TRANSFER_TEMPLATE(): self

Check failure on line 40 in src/Tecan/LiquidClass/MLLLiquidClass.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

Class MLL\Utils\Tecan\LiquidClass\MllLiquidClass referenced with incorrect case: MLL\Utils\Tecan\LiquidClass\MLLLiquidClass.
{
return new self(self::TRANSFER_TEMPLATE);
}

public function name(): string
{
return $this->value;
}
}
116 changes: 116 additions & 0 deletions src/Tecan/Rack/MLLLabWareRack.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?php declare(strict_types=1);

namespace MLL\Utils\Tecan\Rack;

class MLLLabWareRack implements Rack
{
public const A = 'A';
public const MP_CDNA = 'MPCDNA';
public const MP_SAMPLE = 'MPSample';
public const MP_WATER = 'MPWasser';
public const FLUID_X = 'FluidX';
public const MM = 'MM';
public const DEST_LC = 'DestLC';
public const DEST_PCR = 'DestPCR';
public const DEST_TAQMAN = 'DestTaqMan';

public string $value;

public function __construct(string $value)
{
$this->value = $value;
}

public static function A(): self
{
return new self(self::A);
}

public static function MP_CDNA(): self
{
return new self(self::MP_CDNA);
}

public static function MP_SAMPLE(): self
{
return new self(self::MP_SAMPLE);
}

public static function MP_WATER(): self
{
return new self(self::MP_WATER);
}

public static function FLUID_X(): self
{
return new self(self::FLUID_X);
}

public static function MM(): self
{
return new self(self::MM);
}

public static function DEST_LC(): self
{
return new self(self::DEST_LC);
}

public static function DEST_PCR(): self
{
return new self(self::DEST_PCR);
}

public static function DEST_TAQMAN(): self
{
return new self(self::DEST_TAQMAN);
}

public function id(): ?string
{
return null;
}

public function name(): string
{
return $this->value;
}

public function type(): string
{
switch ($this->value) {
case self::A:
return 'Eppis 24x0.5 ml Cooled';
case self::MP_CDNA:
return 'MP cDNA';
case self::MP_SAMPLE:
return 'MP Microplate';
case self::MP_WATER:
return 'Trough 300ml MCA Portrait';
case self::FLUID_X:
return '96FluidX';
case self::MM:
return 'Eppis 32x1.5 ml Cooled';
case self::DEST_LC:
return '96 Well MP LightCycler480';
case self::DEST_PCR:
return '96 Well PCR ABI semi-skirted';
case self::DEST_TAQMAN:
return '96 Well PCR TaqMan';
default:
throw new \Exception('Type not defined for ' . $this->value);
}
}

public function toString(): string
{
return implode(
';',
[
$this->name(),
$this->id(),
$this->type(),
]
);
}
}
11 changes: 0 additions & 11 deletions src/TecanScanner/NoRackIdException.php

This file was deleted.

6 changes: 3 additions & 3 deletions tests/Tecan/BasicCommands/AspirateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use MLL\Utils\Tecan\BasicCommands\Aspirate;
use MLL\Utils\Tecan\LiquidClass\CustomLiquidClass;
use MLL\Utils\Tecan\LiquidClass\MllLiquidClass;
use MLL\Utils\Tecan\LiquidClass\MLLLiquidClass;
use MLL\Utils\Tecan\Location\BarcodeLocation;
use MLL\Utils\Tecan\Location\PositionLocation;
use MLL\Utils\Tecan\Rack\CustomRack;
use MLL\Utils\Tecan\Rack\MllLabWareRack;
use MLL\Utils\Tecan\Rack\MLLLabWareRack;
use PHPUnit\Framework\TestCase;

final class AspirateTest extends TestCase
Expand All @@ -26,7 +26,7 @@ public function testAspirateWithPositionLocation(): void
{
$position = 7;
$volume = 2.2;
$aspirate = new Aspirate($volume, new PositionLocation($position, MllLabWareRack::DEST_PCR()), MllLiquidClass::TRANSFER_TEMPLATE());
$aspirate = new Aspirate($volume, new PositionLocation($position, MLLLabWareRack::DEST_PCR()), MLLLiquidClass::TRANSFER_TEMPLATE());
self::assertNull($aspirate->location->tubeID());
self::assertSame((string) $position, $aspirate->location->position());
self::assertSame('A;DestPCR;;96 Well PCR ABI semi-skirted;' . $position . ';;2.2;Transfer_Template;;', $aspirate->toString());
Expand Down
6 changes: 3 additions & 3 deletions tests/Tecan/BasicCommands/DispenseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

use MLL\Utils\Tecan\BasicCommands\Dispense;
use MLL\Utils\Tecan\LiquidClass\CustomLiquidClass;
use MLL\Utils\Tecan\LiquidClass\MllLiquidClass;
use MLL\Utils\Tecan\LiquidClass\MLLLiquidClass;
use MLL\Utils\Tecan\Location\BarcodeLocation;
use MLL\Utils\Tecan\Location\PositionLocation;
use MLL\Utils\Tecan\Rack\CustomRack;
use MLL\Utils\Tecan\Rack\MllLabWareRack;
use MLL\Utils\Tecan\Rack\MLLLabWareRack;
use PHPUnit\Framework\TestCase;

final class DispenseTest extends TestCase
Expand All @@ -26,7 +26,7 @@ public function testDispenseWithPositionLocation(): void
{
$position = 7;
$volume = 2.2;
$aspirate = new Dispense($volume, new PositionLocation($position, MllLabWareRack::DEST_LC()), MllLiquidClass::TRANSFER_TEMPLATE());
$aspirate = new Dispense($volume, new PositionLocation($position, MLLLabWareRack::DEST_LC()), MLLLiquidClass::TRANSFER_TEMPLATE());
self::assertNull($aspirate->location->tubeID());
self::assertSame((string) $position, $aspirate->location->position());
self::assertSame("D;DestLC;;96 Well MP LightCycler480;{$position};;{$volume};Transfer_Template;;", $aspirate->toString());
Expand Down
10 changes: 5 additions & 5 deletions tests/Tecan/BasicCommands/ReagentDistributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use MLL\Utils\Tecan\BasicCommands\AspirateAndDispenseParameters;
use MLL\Utils\Tecan\BasicCommands\ReagentDistribution;
use MLL\Utils\Tecan\LiquidClass\MllLiquidClass;
use MLL\Utils\Tecan\Rack\MllLabWareRack;
use MLL\Utils\Tecan\LiquidClass\MLLLiquidClass;
use MLL\Utils\Tecan\Rack\MLLLabWareRack;
use MLL\Utils\Tecan\ReagentDistribution\ReagentDistributionDirection;
use PHPUnit\Framework\TestCase;

Expand All @@ -15,16 +15,16 @@ public function testFormatToString(): void
{
$sourceStartPosition = 13;
$sourceEndPosition = 13;
$sourceRack = MllLabWareRack::MM();
$sourceRack = MLLLabWareRack::MM();
$source = new AspirateAndDispenseParameters($sourceRack, $sourceStartPosition, $sourceEndPosition);

$targetStartPosition = 48;
$targetEndPosition = 73;
$targetRack = MllLabWareRack::DEST_PCR();
$targetRack = MLLLabWareRack::DEST_PCR();
$target = new AspirateAndDispenseParameters($targetRack, $targetStartPosition, $targetEndPosition);

$dispenseVolume = 24;
$liquidClass = MllLiquidClass::TRANSFER_MASTERMIX_MP();
$liquidClass = MLLLiquidClass::TRANSFER_MASTERMIX_MP();

$numberOfDitiReuses = 6;
$numberOfMultiDisp = 1;
Expand Down
41 changes: 41 additions & 0 deletions tests/Tecan/CustomCommands/MLLReagentDistributionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php declare(strict_types=1);

namespace MLL\Utils\Tests\Tecan\CustomCommands;

use MLL\Utils\Tecan\CustomCommands\AspirateParameters;
use MLL\Utils\Tecan\CustomCommands\DispenseParameters;
use MLL\Utils\Tecan\CustomCommands\MLLReagentDistribution;
use MLL\Utils\Tecan\LiquidClass\MLLLiquidClass;
use MLL\Utils\Tecan\Rack\MLLLabWareRack;
use PHPUnit\Framework\TestCase;

final class MLLReagentDistributionTest extends TestCase
{
public function testFormatToString(): void
{
$sourceStartPosition = 13;
$sourceRack = MLLLabWareRack::MM();
$source = new AspirateParameters($sourceRack, $sourceStartPosition);

$targetRack = MLLLabWareRack::DEST_PCR();
$target = new DispenseParameters($targetRack, [48, 49, 72, 73]);

$dispenseVolume = 24;
$liquidClass = MLLLiquidClass::TRANSFER_MASTERMIX_MP();

$command = new MLLReagentDistribution(
$source,
$target,
$dispenseVolume,
$liquidClass,
);

$numberOfDitiReuses = MLLReagentDistribution::NUMBER_OF_DITI_REUSES;
$numberOfMultiDisp = MLLReagentDistribution::NUMBER_OF_MULTI_DISP;

self::assertSame(
"R;{$sourceRack->name()};;{$sourceRack->type()};{$sourceStartPosition};{$sourceStartPosition};{$targetRack->name()};;{$targetRack->type()};48;73;{$dispenseVolume};{$liquidClass->name()};{$numberOfDitiReuses};{$numberOfMultiDisp};0;50;51;52;53;54;55;56;57;58;59;60;61;62;63;64;65;66;67;68;69;70;71",
$command->toString()
);
}
}
18 changes: 18 additions & 0 deletions tests/Tecan/LiquidClass/MLLLiquidClassTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php declare(strict_types=1);

namespace MLL\Utils\Tests\Tecan\LiquidClass;

use MLL\Utils\Tecan\LiquidClass\MLLLiquidClass;
use PHPUnit\Framework\TestCase;

final class MLLLiquidClassTest extends TestCase
{
public function testNameOfEnum(): void
{
self::assertSame('DNA_Dilution', MLLLiquidClass::DNA_DILUTION()->name());
self::assertSame('DNA_Dilution_Water', MLLLiquidClass::DNA_DILUTION_WATER()->name());
self::assertSame('Transfer_PCR_Produkt', MLLLiquidClass::TRANSFER_PCR_PRODUKT()->name());
self::assertSame('Transfer_Mastermix_MP', MLLLiquidClass::TRANSFER_MASTERMIX_MP()->name());
self::assertSame('Transfer_Template', MLLLiquidClass::TRANSFER_TEMPLATE()->name());
}
}
Loading

0 comments on commit 88525a4

Please sign in to comment.