-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add MatchKits script for matching and visual
- Loading branch information
1 parent
b2c8810
commit 3c0e513
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,46 @@ | ||
<?php | ||
|
||
require_once 'SNPs.php'; | ||
require_once 'Visualization.php'; | ||
|
||
class MatchKits { | ||
private $kit1Data; | ||
private $kit2Data; | ||
private $matchedData; | ||
|
||
public function loadKitsData($kit1Path, $kit2Path) { | ||
$this->kit1Data = new Dna\Snps\SNPs($kit1Path); | ||
$this->kit2Data = new Dna\Snps\SNPs($kit2Path); | ||
} | ||
|
||
public function matchKits() { | ||
$this->matchedData = []; // Initialize matched data array | ||
foreach ($this->kit1Data->getSnps() as $snp1) { | ||
foreach ($this->kit2Data->getSnps() as $snp2) { | ||
if ($snp1['pos'] == $snp2['pos'] && $snp1['genotype'] == $snp2['genotype']) { | ||
$this->matchedData[] = $snp1; // Add matching SNP to matched data | ||
} | ||
} | ||
} | ||
} | ||
|
||
public function visualizeMatchedData() { | ||
$visualization = new Visualization(); | ||
$visualization->plot_chromosomes($this->matchedData, "matched_data.png", "Matched SNP Data", "Build"); | ||
} | ||
} | ||
|
||
if (php_sapi_name() == "cli") { | ||
$matchKits = new MatchKits(); | ||
echo "Enter file path for Kit 1: "; | ||
$kit1Path = trim(fgets(STDIN)); | ||
echo "Enter file path for Kit 2: "; | ||
$kit2Path = trim(fgets(STDIN)); | ||
|
||
$matchKits->loadKitsData($kit1Path, $kit2Path); | ||
$matchKits->matchKits(); | ||
$matchKits->visualizeMatchedData(); | ||
|
||
echo "Matched data visualization has been generated.\n"; | ||
} | ||
?> |