Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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 @_;
    }

    }

  • #2
    Hi semma,
    your question fits better to PerlMonks:
    A community committed to sharing Perl knowledge and coding tips. The site contains questions and answers, useful snippets, and a library of code.


    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


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


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

        • seqadmin
          Advancing Precision Medicine for Rare Diseases in Children
          by seqadmin




          Many organizations study rare diseases, but few have a mission as impactful as Rady Children’s Institute for Genomic Medicine (RCIGM). “We are all about changing outcomes for children,” explained Dr. Stephen Kingsmore, President and CEO of the group. The institute’s initial goal was to provide rapid diagnoses for critically ill children and shorten their diagnostic odyssey, a term used to describe the long and arduous process it takes patients to obtain an accurate...
          12-16-2024, 07:57 AM
        • seqadmin
          Recent Advances in Sequencing Technologies
          by seqadmin



          Innovations in next-generation sequencing technologies and techniques are driving more precise and comprehensive exploration of complex biological systems. Current advancements include improved accessibility for long-read sequencing and significant progress in single-cell and 3D genomics. This article explores some of the most impactful developments in the field over the past year.

          Long-Read Sequencing
          Long-read sequencing has seen remarkable advancements,...
          12-02-2024, 01:49 PM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, 12-17-2024, 10:28 AM
        0 responses
        33 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 12-13-2024, 08:24 AM
        0 responses
        49 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 12-12-2024, 07:41 AM
        0 responses
        34 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 12-11-2024, 07:45 AM
        0 responses
        46 views
        0 likes
        Last Post seqadmin  
        Working...
        X