Using Perl script including R script to retrive Go annotations for list of accesion number
2
0
Entering edit mode
6.8 years ago
anicet.ebou ▴ 170

Hi everyone,

I have wrote a perl script to retrieve Go annotations (Molecular Function especially with go id). To retrieve go annotation i use a chunck from R that can do this in few lines, and use Perl to format the output. But it's not working.

I have got this error:

Global symbol "$lines" requires explicit package name (did you forget to declare "my $lines"?) at GO_Perl_R line 21.
Global symbol "$lines" requires explicit package name (did you forget to declare "my $lines"?) at GO_Perl_R line 22.
Global symbol "$hits" requires explicit package name (did you forget to declare "my $hits"?) at GO_Perl_R line 22.
Global symbol "$go" requires explicit package name (did you forget to declare "my $go"?) at GO_Perl_R line 24.
Global symbol "@MF" requires explicit package name (did you forget to declare "my @MF"?) at GO_Perl_R line 24.
Global symbol "$id" requires explicit package name (did you forget to declare "my $id"?) at GO_Perl_R line 24.
Global symbol "$lines" requires explicit package name (did you forget to declare "my $lines"?) at GO_Perl_R line 25.
Global symbol "$go" requires explicit package name (did you forget to declare "my $go"?) at GO_Perl_R line 25.
Global symbol "@MF" requires explicit package name (did you forget to declare "my @MF"?) at GO_Perl_R line 25.
Global symbol "@id" requires explicit package name (did you forget to declare "my @id"?) at GO_Perl_R line 25.
Global symbol "$go" requires explicit package name (did you forget to declare "my $go"?) at GO_Perl_R line 25.
Global symbol "@MF" requires explicit package name (did you forget to declare "my @MF"?) at GO_Perl_R line 25.
Global symbol "@term" requires explicit package name (did you forget to declare "my @term"?) at GO_Perl_R line 25.
Execution of GO_Perl_R aborted due to compilation errors.

This is my code :

#! usr/bin/perl

use warnings;
use strict;
use Statistics::R;

my $R = Statistics::R->new();
my $i = 1;
# open the file containing uniprot accession numbers
open (ACC, "acc_numbers.txt") or die "Can't open acc_numbers.txt: $!\n";

while (my @lines=<ACC>) {
    chomp($_);
}

$R -> startR;
$R -> send('library(mygene);');
$R -> run (q`sink('GO_MF.txt')`);
$R -> run (q`sink()`);
$R -> run (
    qq`while($lines){
        res<-query($lines,fields='go')$hits,
        sink('GO_MF.txt', append=TRUE),
        while($i <= length(res$go$MF[[1]]$id) {
            print(paste($lines,"\n",res$go$MF[[1]]$id[$i],"\t",res$go$MF[[1]]$term[$i],"\n"),
        sink(),
        }
    }`
);

exit 0;

Any solution to reach my purpose using Perl script, R script or merging both should be useful.

The output file format is like :

P10214
    GO:xxxxxxx                    "aaaaaaaaaaaaaaaaaaaaa"
    GO:zzzzzzzz                    "bbbbbbbbbbbbbbbbbbbbb"
    ...................                   
Q34F56
    GO:fffffffffff                       "ccccccccccccccccccccccc"
    GO:gggggg                        "hhhhhhhhhhhhhhhhhhhh"
    ...................

Thanks you so much

Perl R Gene Ontology • 1.8k views
ADD COMMENT
1
Entering edit mode
ADD COMMENT
0
Entering edit mode
6.8 years ago
h.mon 35k

If you google for perl global symbol requires explicit package name, there will be so many hits pointing to the correct answer I could not even choose one the link here.

The quickest (but not the best) solution is to remove the use strict; line.

ADD COMMENT
0
Entering edit mode

Not using strict is not recommended for beginners as this leads to more issues and make these more difficult to track. The OP should just read the error messages in full. They give helpful hints.

ADD REPLY

Login before adding your answer.

Traffic: 1912 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6