4 load_marker_locus_associations.pl - load associations between markers and loci.
8 takes a file with two columns: locus names and marker names. Connects the two in the phenome.locus_marker table.
12 Lukas Mueller <lam87@cornell.edu>
21 use CXGN
::DB
::InsertDBH
;
23 use CXGN
::Phenome
::Locus
;
27 getopts
('H:D:f:', \
%args);
29 foreach (values %args) {
30 print STDERR
"param: $_\n";
33 my $dbh = CXGN
::DB
::InsertDBH
->new( { dbname
=> $args{D
},
37 print STDERR
"Reading file $args{f}\n";
38 my @lmas = read_file
($args{f
});
40 foreach my $line (@lmas) {
42 my ($locus_symbol, $marker_name) = split /\t/, $line;
44 my $m = CXGN
::Marker
->new_with_name($dbh, $marker_name);
45 if (!$m) { print STDERR
"Marker not found: $marker_name. Skipping\n"; next; }
46 my $marker_id = $m->marker_id();
48 my $h = $dbh -> prepare
("SELECT locus_id FROM phenome.locus JOIN phenome.locus_alias using(locus_id) WHERE locus_name ilike ? OR locus_alias.alias ilike ? OR locus_symbol ilike ?");
50 $h->execute($locus_symbol, $locus_symbol, $locus_symbol);
53 while (my ($locus_id) = $h->fetchrow_array()) {
57 warn "There are more than 1 loci associated with SNP $marker_name\n";
61 warn "Locus $locus_symbol not found.\n";
63 foreach my $locus_id (@ids) {
64 my $l = CXGN
::Phenome
::Locus
->new($dbh, $locus_id);
66 my $q = $dbh->prepare("INSERT INTO phenome.locus_marker (locus_id, marker_id) VALUES (?, ?)");
67 $q -> execute
($locus_id, $marker_id);
68 print STDERR
"Associated locus $locus_symbol ($locus_id) with marker $marker_name ($marker_id)\n";