Hello Monks, i need your help in searching my two files,in first file(result)frist word of each line represents geneset and rest of the words of that line represents genes represent in that geneset{We can compare it with a draw having number of files in it, i.e geneset is nothing but a draw and files in that draw are genes,I hope you can get my point}each line may contain few hundreds of words and now i need to search each gene(words except first word)in second file(map) and print that line, which has information about genes.


Just have a look at my files
My First file:
#RAW data chr1q21 na S100A3 S100A6 HRNR DRD5P2 ....... HSA04910_INSULIN_SIGNALING_PATHWAY na XRCC5 HRAS .... V$YY1_02 na B3GALT6 DZIP1 RAB1B SART3 FLJ20309 .. MORF_EIF3S2 na HCCS XRCC3 LDHB LDHA OXA1L RPL14 + ... module_486 na CYP3A7 C14orf179 JAG2 INTS1 RBM6 .. CATABOLIC_PROCESS na PGD HNRPD USE1 RNF217 RNASEH1 #second word can be eleminated
My second file
#Map data XRCC5 SNP_A-1966881 1 EFNA1 SNP_A-1877994 9 HRNR SNP_A-1919060 2 XRCC5 SNP_A-1966884 1 XRCC5 SNP_A-1966882 1 HRNR SNP_A-1829030 1
My output file should look some thing like this:
chr1q21 HRNR SNP_A-1829030 1 HRNR SNP_A-1919060 2 EFNA1 SNP_A-1877994 9 HSA04910_INSULIN_SIGNALING_PATHWAY XRCC5 SNP_A-1966884 1 XRCC5 SNP_A-1966882 1 XRCC5 SNP_A-1966881 1 .......

I tried doing this by storing each line in array and from there getting genes (searching has to be done), but the thing is that i want to know is there any thing much simpler way to do this???

THANKS IN ADVANCE. Have a look at my code:
#Actually is a subroutine which is a part of my other program: sub parseGeneEntry { ##purpose of this function is to return everythi +ng from the second tab onwards (these are the genes) $genesList = $_[0]; #print $genesList."\n"; #print "STARTING PARSING \n"; @genes; @genes = split(/\t/,$genesList); shift(@genes); ##removes first entry of array #print $#genes." "; ##for debugging only shift(@genes); #print $#genes." "; #@genes; $toReturn = ""; $counter = 0; foreach $element(@genes){ if ($counter == 0){ $toReturn = $toReturn.$element; $counter++; } else{ $toReturn = $toReturn."\t".$element; } } #$toReturn = $toReturn."\n"; #print length($toReturn)." ".$toReturn."\n\n"; return($toReturn); }

In reply to Searching each word of a file by biomonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.