Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > unknown error

Reply
Thread Tools

unknown error

 
 
a
Guest
Posts: n/a
 
      12-06-2006
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?


 
Reply With Quote
 
 
 
 
anno4000@radom.zrz.tu-berlin.de
Guest
Posts: n/a
 
      12-06-2006
a <> wrote in comp.lang.perl.misc:
> 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
 
Reply With Quote
 
 
 
 
a
Guest
Posts: n/a
 
      12-06-2006
>> 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


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>


 
Reply With Quote
 
anno4000@radom.zrz.tu-berlin.de
Guest
Posts: n/a
 
      12-06-2006
a <> wrote in comp.lang.perl.misc:
> >> 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

>
> 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


> #!/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>
>
>



 
Reply With Quote
 
a
Guest
Posts: n/a
 
      12-06-2006
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);
}


 
Reply With Quote
 
anno4000@radom.zrz.tu-berlin.de
Guest
Posts: n/a
 
      12-06-2006
a <> wrote in comp.lang.perl.misc:
> 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]
 
Reply With Quote
 
Mumia W. (reading news)
Guest
Posts: n/a
 
      12-06-2006
On 12/06/2006 03:32 AM, a wrote:
>>> 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

>
> 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.

--


 
Reply With Quote
 
DJ Stunks
Guest
Posts: n/a
 
      12-06-2006

a wrote:
> 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

 
Reply With Quote
 
a
Guest
Posts: n/a
 
      12-07-2006
> 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.


 
Reply With Quote
 
a
Guest
Posts: n/a
 
      12-07-2006
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
urllib2.URLError: <urlopen error unknown url type: 'http> error usingtwill with python Mark Devine Python 2 06-29-2009 09:20 AM
Assign an unknown value to an unknown variable Vincent Arnoux Ruby 1 08-11-2006 06:12 PM
Getting Printers from AD error "Unknown error (0x80005000)" on Fin =?Utf-8?B?bXVsdGlzeW5j?= ASP .Net 0 12-13-2005 12:29 AM
Blue Screen and unknown error =?Utf-8?B?TXVuZ3Vz?= Microsoft Certification 7 12-22-2004 02:50 PM
Unknown error when open Access db Dmitry Davletbaev ASP .Net 1 02-16-2004 02:36 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57