Skip to content

Commit

Permalink
#144. Make addCriteriaToGene reusable for any criterion
Browse files Browse the repository at this point in the history
  • Loading branch information
Constantine committed Nov 11, 2022
1 parent d94db64 commit baaed8d
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions app/service/dataset/GeneService.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,30 +141,24 @@ public function addCriteriaToGene(array $data) {
$geneSymbols = [];
foreach ($data as $item) {
$symbol = trim($item[0]);
$criteria = array(
"Age-related changes in gene expression/protein activity in humans" => "blue",
"Association of genetic variants and gene expression levels with longevity" => "pink");
$haystack = array_keys($criteria);
if ($gene = Gene::find()
->where(['symbol' => $symbol])
->one()) {
$gene->isHidden = 0;
$gene->save();
if ($item[1] == 'Age-related changes in gene expression/protein activity in humans') {
if (in_array($item[1], $haystack)) {
if (AgeRelatedChange::find()->where([
'gene_id' => $gene->id
])->one()) {
$this
->geneToCommentCauseRepository
->saveFromCriteria($gene, $item[1]);
} else {
echo "Gene " . $item[0] . " doesn't have this type of study: blue". PHP_EOL;
}
} elseif ($item[1] == 'Association of genetic variants and gene expression levels with longevity') {
if (GeneToLongevityEffect::find()->where([
'gene_id' => $gene->id
])->one()) {
$this
->geneToCommentCauseRepository
->saveFromCriteria($gene, $item[1]);
} else {
echo "Gene " . $item[0] . " doesn't have this type of study: pink". PHP_EOL;
echo "Gene " . $item[0] . " doesn't have this type of study: " . $criteria[$item[1]] . PHP_EOL;
}
}
} else {
Expand Down

0 comments on commit baaed8d

Please sign in to comment.