Skip to content

Commit

Permalink
feat: Updated src/Snps/SNPs.php
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Mar 12, 2024
1 parent 3c0e513 commit a0211c4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Snps/SNPs.php
Expand Up @@ -2461,6 +2461,33 @@ public function toVcf(
// // If there are no SNPs here, skip
// if (count($snp_indices) === 0) {
// continue;
/**
* Matches SNPs with another SNPs object and returns a new SNPs object with the matching SNPs.
*
* @param SNPs $otherKit The other SNPs object to match with.
* @return SNPs A new SNPs object containing the matching SNPs.
*/
public function matchWith(SNPs $otherKit): SNPs
{
$matchedSnps = []; // Initialize an array to store the matched SNPs

// Iterate over the SNPs in the current object
foreach ($this->_snps as $snp) {
// Iterate over the SNPs in the other object
foreach ($otherKit->getSnps() as $otherSnp) {
// Check if the SNP positions and alleles match
if ($snp['pos'] == $otherSnp['pos'] && $snp['genotype'] == $otherSnp['genotype']) {
$matchedSnps[] = $snp; // Add the matching SNP to the array
}
}
}

// Create a new SNPs object with the matched SNPs
$matchedSnpsObject = new SNPs();
$matchedSnpsObject->setSNPs($matchedSnps);

return $matchedSnpsObject; // Return the new SNPs object
}
// }

// $orig_range_len = $orig_end - $orig_start;
Expand Down

0 comments on commit a0211c4

Please sign in to comment.