unknown error

Discussion in 'Perl Misc' started by a, Dec 6, 2006.

  1. a

    a Guest

    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, Dec 6, 2006
    #1
    1. Advertising

  2. a

    -berlin.de Guest

    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
    -berlin.de, Dec 6, 2006
    #2
    1. Advertising

  3. a

    a Guest

    >> 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>
    a, Dec 6, 2006
    #3
  4. a

    -berlin.de Guest

    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>
    >
    >
    -berlin.de, Dec 6, 2006
    #4
  5. a

    a Guest

    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, Dec 6, 2006
    #5
  6. a

    -berlin.de Guest

    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]
    -berlin.de, Dec 6, 2006
    #6
  7. 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.

    --
    Mumia W. (reading news), Dec 6, 2006
    #7
  8. a

    DJ Stunks Guest

    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
    DJ Stunks, Dec 6, 2006
    #8
  9. a

    a Guest

    > 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, Dec 7, 2006
    #9
  10. a

    a Guest

    > 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, Dec 7, 2006
    #10
  11. a

    -berlin.de Guest

    a <> wrote in comp.lang.perl.misc:
    > > 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.


    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
    -berlin.de, Dec 7, 2006
    #11
  12. a

    a Guest

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


    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, Dec 7, 2006
    #12
  13. a

    -berlin.de Guest

    a <> wrote in comp.lang.perl.misc:
    > >> 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

    >
    > 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
    -berlin.de, Dec 7, 2006
    #13
  14. a

    a Guest

    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.
    a, Dec 8, 2006
    #14
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dmitry Davletbaev

    Unknown error when open Access db

    Dmitry Davletbaev, Feb 13, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    389
    Kevin Spencer
    Feb 16, 2004
  2. Gilles Lambert

    Unknown error from Application_Error

    Gilles Lambert, Apr 26, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    304
    Peter O'Reilly
    Apr 26, 2004
  3. =?Utf-8?B?bXVsdGlzeW5j?=
    Replies:
    0
    Views:
    2,157
    =?Utf-8?B?bXVsdGlzeW5j?=
    Dec 13, 2005
  4. Mark Devine
    Replies:
    2
    Views:
    1,064
    amadain
    Jun 29, 2009
  5. Vincent Arnoux
    Replies:
    1
    Views:
    231
    Arnaud Bergeron
    Aug 11, 2006
Loading...

Share This Page