Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • semna
    Member
    • Apr 2010
    • 55

    #1

    just perl script

    Hi
    I am a new user in perl. I want to make a subroutine that takes the taxonomy-id as input and returns the list of leaf nodes as output and I wrote this script but it's not working. Any suggestion? Thanks in advance.

    #!/usr/bin/perl
    use strict;
    my @leafnodes_list = getleafnodes (my $taxid);
    print @leafnodes_list;
    sub getleafnodes
    {
    my ($taxid) = @_;
    print "type Taxid number:";
    $taxid = <STDIN>;
    chomp $taxid;
    foreach (@_){
    "getz [taxonomy-ID:$taxid] >_ tax_down";
    return @_;
    }

    }
  • zhidkov.ilia
    Member
    • Dec 2010
    • 25

    #2
    Hi semma,
    your question fits better to PerlMonks:


    Can you give an example of expected INPUT and expected OUTPUT, it might help to figure out where is your bug in script.

    Ilia
    Last edited by zhidkov.ilia; 07-02-2011, 03:41 AM.

    Comment

    • semna
      Member
      • Apr 2010
      • 55

      #3
      HI,
      This is actually used to make a tree by using taxonomy ID. input is just a number and output is a list of different names and numbers that I used getz command for that.
      thanks

      Comment

      • gringer
        David Eccles (gringer)
        • May 2011
        • 845

        #4
        Here's what your code does as it is

        I need to re-order your code a tiny bit to get my head around how it works...

        Code:
         1 #!/usr/bin/perl
         2 use strict;
         3 sub getleafnodes {
         4   my ($taxid) = @_;
         5   print "type Taxid number:";
         6   $taxid = <STDIN>;
         7   chomp $taxid;
         8     foreach (@_){
         9       "getz [taxonomy-ID:$taxid] >_ tax_down";
        10       return @_;
        11    }
        12 }
        13 my @leafnodes_list = getleafnodes (my $taxid);
        14 print @leafnodes_list;
        Up to line 3, things look good, although I'd suggest 'use warnings;' as well.
        Line 4: the scalar variable $taxid is set to the first argument of the function getleafnodes. Nothing is done with this variable before it is assigned a new value on line 6.
        Line 5: Print (without line breaks) the string "type Taxid number:"
        Line 6: read a single line from standard input, store the result (including ending line break) in the scalar variable $taxid.
        Line 7: Remove the final line break from the variable $taxid.
        Line 8: loop through the arguments of the function (@_), setting the default scalar variable (i.e. $_) to that argument.
        Line 9: Do absolutely nothing with the string "getz [taxonomy-ID:$taxid] >_ tax_down" -- no printing, no evaulation, no assignment.
        Line 10: return the arguments of the function (@_), breaking out of the loop in the process
        Lines 11-12 are never reached by any code
        Line 13: create an array @leafnodes_list, which is set to the return value of the function getleafnodes, given an argument that is an undefined value, created due to the initialisation of a new scalar variable $taxid. The function returns the arguments sent to the function, so this will be an array containing a single element, namely an undefined value.
        Line 14: print the elements of the array @leafnodes_list, not separated by anything. As the only element in the list is the undefined value, this will not print anything.

        So, if you're lucky, this function will probably output one thing, "type Taxid number:". If that is what you wanted to do, here's a simpler way to do it:
        Code:
        #!/usr/bin/perl
        print "type Taxid number:"
        Could you please explain in a bit more detail what you were trying to do?

        Comment

        Latest Articles

        Collapse

        • SEQadmin2
          Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
          by SEQadmin2



          Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

          Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
          ...
          10-14-2026, 09:55 AM
        • SEQadmin2
          New Genomics Technologies Take Aim at Long-Standing Limits
          by SEQadmin2


          Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

          We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
          ...
          09-28-2026, 10:25 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, Yesterday, 11:13 AM
        0 responses
        16 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, Yesterday, 10:48 AM
        0 responses
        17 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-15-2026, 10:52 AM
        0 responses
        35 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-14-2026, 05:39 AM
        0 responses
        42 views
        0 reactions
        Last Post SEQadmin2  
        Working...