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
          Current Approaches to Protein Sequencing
          by seqadmin


          Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
          04-04-2024, 04:25 PM
        • seqadmin
          Strategies for Sequencing Challenging Samples
          by seqadmin


          Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
          03-22-2024, 06:39 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, 04-11-2024, 12:08 PM
        0 responses
        24 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 10:19 PM
        0 responses
        25 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 09:21 AM
        0 responses
        21 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-04-2024, 09:00 AM
        0 responses
        52 views
        0 likes
        Last Post seqadmin  
        Working...
        X