minor fixes
[sgn.git] / lib / CXGN / Blast / SeqQuery / Plugin / TomatoGenomeIds.pm
blob98bfd36165ba3aca2b51bb590e563f8ebbbbbb07
2 package CXGN::Blast::SeqQuery::Plugin::TomatoGenomeIds;
4 use Moose;
6 sub name {
7 return "tomato genome identifiers";
10 sub type {
11 return 'nucleotide';
14 sub example {
15 return "Solyc01g005370
16 Solyc01g005590
17 Solyc01g016780
18 Solyc01g058740
19 Solyc01g080500";
22 sub validate {
23 my $self = shift;
24 my $c = shift;
25 my $input = shift;
27 my @ids = split /\s+/, $input;
29 my $schema = $c->dbic_schema("Bio::Chado::Schema");
30 my $rna_id = $schema->resultset("Cv::Cvterm")->find( { name=>'mRNA' })->cvterm_id();
32 my @missing = ();
33 foreach my $id (@ids) {
34 print STDERR "Validating $id... ";
35 my $rs = $schema->resultset("Sequence::Feature")->search( { type_id=>$rna_id, name => { ilike => "$id".'.%.1' } } );
36 if ($rs->count() ==0) {
37 print STDERR " not found.\n";
38 push @missing, $id;
40 else { print STDERR "OK\n"; }
43 if (@missing) {
44 return "The folloing ids entered do not exist: ".(join ",", @missing);
46 else {
47 return "OK";
51 sub process {
52 my $self = shift;
53 my $c = shift;
54 my $input = shift;
56 my @ids = split /\s+/, $input;
58 my $schema = $c->dbic_schema("Bio::Chado::Schema");
59 my $rna_id = $schema->resultset("Cv::Cvterm")->find( { name=>'mRNA' })->cvterm_id();
60 print STDERR "RNA: $rna_id\n";
61 my @seqs = ();
62 foreach my $id (@ids) {
63 my $rs = $schema->resultset("Sequence::Feature")->search( { type_id=>$rna_id, name => { ilike => "$id".'.%.1' } } );
64 if (my $row = $rs->next()) {
66 push @seqs, ">".$row->name."\n".$row->residues();
68 else {
69 die "ID $id does not exist!";
72 my $sequence = join "\n", @seqs;
73 print STDERR "SEQUENCE = $sequence\n";
75 return $sequence;