find a first column value ...

Ask a Question related to PERL Modules, Design and Development.

  1. #1

    Default find a first column value ...

    203252 GB|AI461105 GB|AI900630 GB|AI900894 GB|AI901187
    203253 GB|AI736220 GB|AW780891 GB|BE806781 GB|BG157087
    203254 GB|AI440899 GB|AW185396 GB|AW185458 GB|AW152990
    203255 GB|AI416923 GB|AI437726 GB|AI437966 GB|AI438062
    203256 GB|AI441714 GB|AI930592 GB|AI855868 GB|AI856032

    I am new with perl and my problam is if I give any accession no like
    AW780891
    than it should find the first column value like 203253.
    IS any Module there to do this type of work ?
    Thanks.

    BD Guest

  2. Similar Questions and Discussions

    1. find null value in any column
      Hi, Assume I have a table with only 1 row and all column is 'int'. I just wonder is it possible to use SQL to check if any one of those column...
    2. Find specific column names AND their values.
      Okay, so I'm working on this project that tracks communities and how they're doing. The communities are judged based on their indicators. There...
    3. Find a column by name
      How do I find a column in a grid by the name of the column? I find I'm constantly having to change the cell numbers because the order of the...
    4. How do I find the index of a DG column with a specific name?
      I have a column called "notes" which may change position in the datagrid. How do I find the index of this column based on its name?
    5. how to Add different controls(textBox,DropDownList or some ) in the same column,based upon the value in the previous column (Say second Colum which contain dropdown with some values) ?
      I am new to ASP.NET. I am facing problem with datagrid. I will explain prob now. In the datagrid the first column is name in the second...
  3. #2

    Default Re: find a first column value ...


    BD wrote:
    > 203252 GB|AI461105 GB|AI900630 GB|AI900894 GB|AI901187
    > 203253 GB|AI736220 GB|AW780891 GB|BE806781 GB|BG157087
    > 203254 GB|AI440899 GB|AW185396 GB|AW185458 GB|AW152990
    > 203255 GB|AI416923 GB|AI437726 GB|AI437966 GB|AI438062
    > 203256 GB|AI441714 GB|AI930592 GB|AI855868 GB|AI856032
    >
    > I am new with perl and my problam is if I give any accession no like
    > AW780891
    > than it should find the first column value like 203253.
    > IS any Module there to do this type of work ?
    What "type of work"? You mean parse a file and build an index? That's
    rather general. So general that the interface to the module would be
    close in complexity to a general programming language. But you apready
    have a general purpose prgramming language - Perl. So just do it.

    Actually for more complex parrsing tasks there are numerous modules to
    help you, but even implementing the simplest grammar in, say,
    Parse::RecDescent is orders of mangnitude more complex than your
    starting problem.

    Of course your problem is badly underspecified - what for example is
    the significance of the string 'GB|'? Is the mapping many-to-one or
    many-to-many? Where is the data comining from? Are you going to do one
    look up or several?

    use strict;
    use warnings;

    my %accession_index;

    while (<DATA>) {
    chomp;
    my ($number, @accessions) = split;
    $accession_index{$_}=$number for @accessions;
    }

    my $accession_number='AW780891';

    print $accession_index{'GB|'.$accession_number},"\n";

    __DATA__
    203252 GB|AI461105 GB|AI900630 GB|AI900894 GB|AI901187
    203253 GB|AI736220 GB|AW780891 GB|BE806781 GB|BG157087
    203254 GB|AI440899 GB|AW185396 GB|AW185458 GB|AW152990
    203255 GB|AI416923 GB|AI437726 GB|AI437966 GB|AI438062
    203256 GB|AI441714 GB|AI930592 GB|AI855868 GB|AI856032

    Brian McCauley Guest

  4. #3

    Default Re: find a first column value ...

    BD schreef:
    > if I give any accession no like AW780891
    > than it should find the first column value like 203253.
    If you only need to find one value per run:

    #!/usr/bin/perl
    use strict;
    use warnings;

    while ( <DATA> )
    {
    / ^ (\d+) .* [ ]GB[|] ${ARGV[0]} [ ] /x
    and print "$1\n" and exit(0)
    }
    exit(1)

    __DATA__
    203252 GB|AI461105 GB|AI900630 GB|AI900894 GB|AI901187
    203253 GB|AI736220 GB|AW780891 GB|BE806781 GB|BG157087
    203254 GB|AI440899 GB|AW185396 GB|AW185458 GB|AW152990
    203255 GB|AI416923 GB|AI437726 GB|AI437966 GB|AI438062
    203256 GB|AI441714 GB|AI930592 GB|AI855868 GB|AI856032


    --
    Affijn, Ruud

    "Gewoon is een tijger."


    Dr.Ruud Guest

  5. #4

    Default Re: find a first column value ...


    Thanks :)

    BD Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139