Skip to content

Commit fc61859

Browse files
committed
Add prototype script for inferring interactions
We create genetic lethal interactions when appropriate single and double alleles and annotation are in a session. Refs pombase/pombase-chado#692
1 parent c01491b commit fc61859

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/usr/bin/env perl
2+
3+
# Create genotype-genotype interactions from double allele mutants
4+
#
5+
# See: https://github.com/pombase/pombase-chado/issues/692
6+
7+
use strict;
8+
use warnings;
9+
use Carp;
10+
11+
use utf8;
12+
13+
use File::Basename;
14+
15+
BEGIN {
16+
my $script_name = basename $0;
17+
18+
if (-f $script_name && -d "../etc") {
19+
# we're in the scripts directory - go up
20+
chdir "..";
21+
}
22+
};
23+
24+
use lib qw(lib);
25+
26+
use Canto::Config;
27+
use Canto::Track;
28+
use Canto::TrackDB;
29+
use Canto::Meta::Util;
30+
31+
my $app_name = Canto::Config::get_application_name();
32+
33+
$ENV{CANTO_CONFIG_LOCAL_SUFFIX} ||= 'deploy';
34+
35+
my $suffix = $ENV{CANTO_CONFIG_LOCAL_SUFFIX};
36+
37+
if (!Canto::Meta::Util::app_initialised($app_name, $suffix)) {
38+
die "The application is not yet initialised, try running the canto_start " .
39+
"script\n";
40+
}
41+
42+
my $config = Canto::Config::get_config();
43+
44+
push @{$config->{export_type_to_allele_type}->{nonsense_mutation}}, { name => 'nonsense mutation' };
45+
46+
my $track_schema = Canto::TrackDB->new(config => $config);
47+
48+
use utf8; use Canto::Track::OntologyLookup;
49+
50+
my $lookup = Canto::Track::get_adaptor($config, "ontology");
51+
52+
53+
BEGIN { binmode STDOUT, ":encoding(UTF-8)"; }
54+
55+
sub is_pop {
56+
my $a = shift;
57+
my $ag_rs = $a->genotypes();
58+
59+
for my $single_allele_genotype ($ag_rs->all()) {
60+
return undef unless $single_allele_genotype->alleles()->count() == 1;
61+
62+
for my $single_allele_genotype_annotation ($single_allele_genotype->annotations()) {
63+
64+
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+
) {
69+
return $single_allele_genotype;
70+
}
71+
}
72+
}
73+
74+
die "not pop\n";
75+
76+
return undef;
77+
};
78+
79+
sub make_interaction {
80+
my ($curs_schema, $interaction_type,
81+
$double_mutant_genotype_annotation, $allele_1_genotype,
82+
$allele_2_genotype) = @_;
83+
84+
my %create_args = (
85+
interaction_type => $interaction_type,
86+
primary_genotype_annotation_id =>
87+
$double_mutant_genotype_annotation->genotype_annotation_id(),
88+
genotype_a_id => $allele_1_genotype->genotype_id(),
89+
genotype_b_id => $allele_2_genotype->genotype_id(),
90+
);
91+
92+
print "created interaction\n";
93+
94+
$curs_schema->create_with_type('GenotypeInteraction', \%create_args);
95+
}
96+
97+
my $proc = sub {
98+
my $curs = shift;
99+
my $curs_schema = shift;
100+
my $track_schema = shift;
101+
102+
my $rs = $curs_schema->resultset("Annotation")
103+
->search({ type => "phenotype" });
104+
105+
while (defined (my $an = $rs->next())) {
106+
my $data = $an->data();
107+
next unless $data->{term_ontid} eq "FYPO:0002061";
108+
my $genotype_annotations_rs = $an->genotype_annotations();
109+
my $genotype_annotation = $genotype_annotations_rs->first();
110+
111+
if ($genotype_annotation->genotype_interactions()->count() > 0) {
112+
next;
113+
}
114+
115+
my $double_allele_genotype = $genotype_annotation->genotype();
116+
my $alleles_rs = $double_allele_genotype->alleles();
117+
next unless $alleles_rs->count() == 2;
118+
my $allele_1 = $alleles_rs->next();
119+
next unless $allele_1->type() eq "deletion";
120+
my $allele_1_genotype = is_pop($allele_1);
121+
next unless defined $allele_1_genotype;
122+
my $allele_2 = $alleles_rs->next();
123+
next unless $allele_2->type() eq "deletion";
124+
my $allele_2_genotype = is_pop($allele_2);
125+
next unless defined $allele_2_genotype;
126+
127+
print $curs->curs_key(), "\n";
128+
make_interaction($curs_schema, 'Synthetic Growth Defect',
129+
$genotype_annotation, $allele_1_genotype,
130+
$allele_2_genotype);
131+
}
132+
};
133+
134+
my $transaction = sub {
135+
Canto::Track::curs_map($config, $track_schema, $proc);
136+
};
137+
138+
$track_schema->txn_do($transaction);
139+
140+

0 commit comments

Comments
 (0)