unknown error

A

a

The perl installed is 5.8


<snippet>
use File::Temp;

<snippet>

my $tmp = new File::Temp( DIR => '.');

Can't locate object method "new" via package "File::Temp" at
filter-stage-1.prl line 47, <> line 6.

How to solve the problem?
 
A

anno4000

a said:
The perl installed is 5.8


<snippet>
use File::Temp;

<snippet>

my $tmp = new File::Temp( DIR => '.');

Can't locate object method "new" via package "File::Temp" at
filter-stage-1.prl line 47, <> line 6.

How to solve the problem?

In isolation your two lines don't produce an error. Post a short
example that does show it.

Anno
 
A

a

The perl installed is 5.8
In isolation your two lines don't produce an error. Post a short
example that does show it.

Anno

I've tried some modifications but they don't work. I know the purpose is to
create a temp file only and therefore have tried to circumvent it by some
modifications. Unfortunately, that has created other problems downstream and
it seems that I have to confront with the problem.


#!/usr/bin/perl
##!/usr/bin/env perl

use File::Temp;
#require File::Temp;

if( grep /^--?h$/, @ARGV ) {
exec("perldoc $0");
}
my $NSEG_THRESHOLD = .5;
my $TRF_THRESHOLD = .5;
my $MIN_LENGTH = 50;

my $TRF_COMMAND = $ENV{'TRF_COMMAND'} || "trf";
my $NSEG_COMMAND = $ENV{'NSEG_COMMAND'} || "nseg";
my ($head, $body);
my $repeat_num = 1;
my $num_deleted = 0;
my $num_skipped = 0;
my $line = 0;
while(<>)
{
++$line;
chomp;
next if /^#/; # Allow embedded comments.

if( /^>/ )
{
my $xx = $_;
my $nseg;
my $trf;
if( length($body) > $MIN_LENGTH) {
my $tmp = new File::Temp( DIR => '.');
#my $tmp = File::Temp( DIR => '.');
#$tmp = '.';
print $tmp "$head (RR=$repeat_num)\n";
print $tmp "$body\n";
$nseg = nseg($tmp, $body);
<snippet>
 
A

anno4000

a said:
I've tried some modifications but they don't work. I know the purpose is to
create a temp file only and therefore have tried to circumvent it by some
modifications. Unfortunately, that has created other problems downstream and
it seems that I have to confront with the problem.

I asked you to post an example that shows the error. Your code below
shows nothing. It doesn't compile because there are three unclosed
braces (which you made hard to see by lack of indentation). After
correcting that and providing some input data (which you should have
done) it turns out that the line in point will never be executed because
the variable $body is never assigned a value.

If you want help invest a little more effort and present code that
shows your problem. So far you've only been wasting everybody's time.

Anno
 
A

a

Sorry Anno. I hope this time I get your meaning correct. I thought I should
post the relevant codes so to save everybody's time. Now I post all the
codes with irrelevant comments removed.


#!/usr/bin/perl
##!/usr/bin/env perl
#
# Status is printed to STDERR, the resulting "good" repeats to STDOUT.
#

use File::Temp;
#require File::Temp;

if( grep /^--?h$/, @ARGV ) {
exec("perldoc $0");
}

my $NSEG_THRESHOLD = .5;
my $TRF_THRESHOLD = .5;
my $MIN_LENGTH = 50;

my $TRF_COMMAND = $ENV{'TRF_COMMAND'} || "trf";
my $NSEG_COMMAND = $ENV{'NSEG_COMMAND'} || "nseg";


my ($head, $body);
my $repeat_num = 1;
my $num_deleted = 0;
my $num_skipped = 0;
my $line = 0;
while(<>) {
++$line;
chomp;
next if /^#/; # Allow embedded comments.

if( /^>/ ) {
my $xx = $_;
my $nseg;
my $trf;
if( length($body) > $MIN_LENGTH) {
my $tmp = new File::Temp( DIR => '.');
#my $tmp = File::Temp( DIR => '.');
#$tmp = '.';
print $tmp "$head (RR=$repeat_num)\n";
print $tmp "$body\n";
$nseg = nseg($tmp, $body);
$trf = trf($tmp, $body);
$tmp->close();
$tmp = undef; # Remove any reference counts so it's deleted.

if( $nseg <= $NSEG_THRESHOLD && $trf <= $TRF_THRESHOLD )
{
printf("$head (RR=$repeat_num. TRF=%.3f NSEG=%.3f)\n", $trf, $nseg);
for(my $ii = 0; $ii < length($body); $ii += 80) {
print substr($body, $ii, 80), "\n";
}
}

else {
print STDERR "deleting $header: $nseg / $trf\n";
++$num_deleted;
}

++$repeat_num;
}

else {
++$num_skipped;
}
$head = $xx;
$body = '';
}

else {
die("Improperly formatted file: offensive line #$line was\n$_\n") if
/[^ATGC]/;

$body .= $_;
}
}
print STDERR "$num_deleted deleted. $repeat_num saved. $num_skipped skipped
for length.\n";

sub nseg {
my ($file, $text) = @_;
local *NSEG;
my $nseg = $NSEG_COMMAND;
open(NSEG, "$nseg $file -x -c 100 |");
my $len = 0;
while(<NSEG>) {
chomp;
next if /^>/;

s/n//g;
s/N//g;

$len += 1*length($_);
}
close(NSEG);
return (length($text)-$len) / length($text);
}

sub trf {
my ($file, $text) = @_;
local *TRF;
my $trf = $TRF_COMMAND;

system("$trf $file 2 7 7 80 10 50 500 -f -d -m > /dev/null");
open(TRF, "<$file.2.7.7.80.10.50.500.mask") or die($!);
my $len = 0;

while(<TRF>) {
chomp;
next if /^>/;
s/n//g;
s/N//g;
$len += 1*length($_);
}
close(TRF);

# TRF produces many output files.
unlink "$file.2.7.7.80.10.50.500.mask";
unlink "$file.2.7.7.80.10.50.500.dat";
unlink "$file.2.7.7.80.10.50.500.1.txt.html";
unlink "$file.2.7.7.80.10.50.500.1.html";

return (length($text)-$len) / length($text);
}
 
A

anno4000

a said:
Sorry Anno. I hope this time I get your meaning correct. I thought I should
post the relevant codes so to save everybody's time. Now I post all the
codes with irrelevant comments removed.

Oh boy! 130+ lines of code which isn't strict-compatible ("$header"
is undeclared). Plus, no input data, so we are supposed to find out on
our own how to get input past your various checks. After doing that
it seems that the tempfile is created just fine, though there seem to
be a lot of other problems. I'm not pursuing this farther.

Anno

[code snipped]
 
M

Mumia W. (reading news)

In isolation your two lines don't produce an error. Post a short
example that does show it.

Anno

I've tried some modifications but they don't work. I know the purpose is to
create a temp file only and therefore have tried to circumvent it by some
modifications. Unfortunately, that has created other problems downstream and
it seems that I have to confront with the problem.
[... code snipped ...]

Say that again please. I couldn't understand your paragraph. Please
write it again differently--more completely and accurately.

I want to understand what the problem is before I look at the program.
 
D

DJ Stunks

a said:
The perl installed is 5.8


<snippet>
use File::Temp;

<snippet>

my $tmp = new File::Temp( DIR => '.');

Can't locate object method "new" via package "File::Temp" at
filter-stage-1.prl line 47, <> line 6.

How to solve the problem?

I'd say File::Temp isn't installed, or, since it's core (I believe),
inaccessible for some reason - ie permissions?

I don't ever use the OO syntax for that module.

-jp
 
A

a

I'd say File::Temp isn't installed, or, since it's core (I believe),
inaccessible for some reason - ie permissions?

I don't ever use the OO syntax for that module.

-jp

How to check whether it has been installed or not, and its permission? I
hope that will be the clue.
 
A

a

Say that again please. I couldn't understand your paragraph. Please write
it again differently--more completely and accurately.

I want to understand what the problem is before I look at the program.

The program has some non-understandable (to me) or Google-unsearchable
descriptions but may be useful clues to the advanced perl and UNIX users.
Hope that will help.

=head1 OPTIONS

none other than "-h" (the output of which you're reading),
but you will either want trf and nseg in your PATH, or you will want
to set the environment variables TRF_COMMAND and NSEG_COMMAND to provide
the executable.

=head1 DESCRIPTION

This tool takes a repeat library, which is a Fasta-formatted sequence file,
and
filters out any sequence that is deemed to be more than 50% low-complexity
by either
TRF or NSEG or both. Note that one algorithm needs to make the
determination; we don't
check the total number of unique bases masked out by TRF and NSEG
individually.

=head1 ENVIRONMENT VARIABLES

In order for this program to find TRF and NSEG, you need to either place
said programs
in your PATH, or you need to add the environment variables TRF_COMMAND and
NSEG_COMMAND.
The value of those variables should be the path at which the respective
program can be
found.

=cut
 
A

anno4000

a said:
How to check whether it has been installed or not, and its permission? I
hope that will be the clue.

Run

perl -MFile::Temp -e';'

from the command line. If File::Temp is accessible it will run
silently, otherwise you'll see an error message.

Anno
 
A

a

How to check whether it has been installed or not, and its permission? I
Run

perl -MFile::Temp -e';'

from the command line. If File::Temp is accessible it will run
silently, otherwise you'll see an error message.

Anno

Thank for Anno again, as I don't expect you'd answer a stupid newbie like
me. The program runs silently and that means the problem is not caused as
suggested by DJ Stunks. As you mention, the problem is unable to be solved
here. I don't know how to put necessary codes and files here. Thanks for all
your help. Hope the authors would respond me, for the sake of academic
research.
 
A

anno4000

a said:
Thank for Anno again, as I don't expect you'd answer a stupid newbie like
me.

I didn't mean to say you're stupid, just inexperienced.

Your chances of receiving useful replies are best when you post a
small program that demonstrates the problem you're having that we
can actually run and change around. Preparing such a program from
a large (and probably messy) chunk of code isn't necessarily easy,
but someone must do it and you're the one who knows the code best.

At the same time, reducing a program with a mysterious error to
a minimal program that still shows the error is a useful debugging
technique. More often than not the process will uncover what's
wrong before you even have to post to Usenet. Try it with your
problem and see where it leads you.

Anno
 
A

a

Now I'm thinking that it might be the module/installation problem. I've
tried googling perl module library location and search on the linux platform
but got no results. Is that the File::tmp module incorporated in perl and
therefore I'm unable to see the original codes? I'd like to know how the
object is constructed to get more insights, thanks a lot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top