Skip to content

Commit 86f10f2

Browse files
committed
Don't create duplicate inferred interactions
Refs pombase/pombase-chado#692
1 parent 430a7df commit 86f10f2

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

etc/make_interactions_from_double_mutants.pl

+38-7
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ sub is_pop {
6262
for my $single_allele_genotype_annotation ($single_allele_genotype->annotations()) {
6363

6464
my $term_ontid = $single_allele_genotype_annotation->data()->{term_ontid};
65-
my $res = $lookup->lookup_by_id(id => $term_ontid,
66-
include_subset_ids => 1);
67-
if (grep { $_ eq 'is_a(FYPO:0002057)' } @{$res->{subset_ids}}
68-
) {
65+
my $res = $lookup->lookup_by_id(id => $term_ontid, include_subset_ids => 1);
66+
67+
if (grep { $_ eq 'is_a(FYPO:0002057)' } @{$res->{subset_ids}}) {
6968
return $single_allele_genotype;
7069
}
7170
}
@@ -76,6 +75,28 @@ sub is_pop {
7675
return undef;
7776
};
7877

78+
79+
sub make_key
80+
{
81+
my $evidence = shift;
82+
my $genotype_annotation = shift;
83+
my $allele_1_genotype = shift;
84+
my $allele_2_genotype = shift;
85+
86+
my $data = $genotype_annotation->annotation->data();
87+
88+
my $annotation_key =
89+
join ('---',
90+
$genotype_annotation->genotype->display_name($config),
91+
$genotype_annotation->annotation->type(),
92+
$data->{term_ontid});
93+
94+
return join (':-:',$evidence,
95+
$annotation_key,
96+
$allele_1_genotype->display_name($config),
97+
$allele_2_genotype->display_name($config));
98+
}
99+
79100
sub make_interaction {
80101
my ($curs_schema, $interaction_type,
81102
$double_mutant_genotype_annotation, $allele_1_genotype,
@@ -84,16 +105,16 @@ sub make_interaction {
84105
my %create_args = (
85106
interaction_type => $interaction_type,
86107
primary_genotype_annotation_id =>
87-
$double_mutant_genotype_annotation->genotype_annotation_id(),
108+
$double_mutant_genotype_annotation->genotype_annotation_id(),
88109
genotype_a_id => $allele_1_genotype->genotype_id(),
89110
genotype_b_id => $allele_2_genotype->genotype_id(),
90111
);
91112

92-
print "created interaction\n";
93-
94113
$curs_schema->create_with_type('GenotypeInteraction', \%create_args);
95114
}
96115

116+
my %created_interactions = ();
117+
97118
my $proc = sub {
98119
my $curs = shift;
99120
my $curs_schema = shift;
@@ -124,6 +145,16 @@ sub make_interaction {
124145
my $allele_2_genotype = is_pop($allele_2);
125146
next unless defined $allele_2_genotype;
126147

148+
my $seen_key = make_key('Synthetic Growth Defect',
149+
$genotype_annotation, $allele_1_genotype,
150+
$allele_2_genotype);
151+
152+
if ($created_interactions{$seen_key}) {
153+
next;
154+
} else {
155+
$created_interactions{$seen_key} = 1;
156+
}
157+
127158
print $curs->curs_key(), "\n";
128159
make_interaction($curs_schema, 'Synthetic Growth Defect',
129160
$genotype_annotation, $allele_1_genotype,

0 commit comments

Comments
 (0)