Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • ckant
    Junior Member
    • Sep 2011
    • 5

    perl script for fetching lines, if a pattern is given

    I am very new to this field.I have two file (few lines of files are given below), first one is tab delimited text file contains contig numbers and respective annotations given in the same line . second file i am having contains only ids. I need to fetch annotations from the first file for the ids present in second file.May you please provide with a perl script.

    first file:-
    contig06610 Q9SQV1 GO:0000184 GO:0006139 GO:0006139 nucleobase, nucleoside, nucleotideandnucleicacidmetabolicprocess biological_process
    contig07217 B0S733 GO:0000184 GO:0006139 GO:0006139 nucleobase, nucleoside, nucleotideandnucleicacidmetabolicprocess biological_process
    contig08155 O13828 GO:0000184 GO:0006139 GO:0006139 nucleobase, nucleoside, nucleotideandnucleicacidmetabolicprocess biological_process
    contig10605 O01510 GO:0000184 GO:0006139 GO:0006139 nucleobase, nucleoside, nucleotideandnucleicacidmetabolicprocess biological_process
    contig12296 Q9FJR0 GO:0000184 GO:0006139 GO:0006139 nucleobase, nucleoside, nucleotideandnucleicacidmetabolicprocess biological_process


    second file:-
    contig07217
    contig07217
    contig10605
    contig12296
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #2
    Forget perl, just use grep (grep -f file_with_ids file_to_search).

    Comment

    • ctseto
      Member
      • Oct 2013
      • 44

      #3
      Originally posted by dpryan View Post
      Forget perl, just use grep (grep -f file_with_ids file_to_search).
      Didn't even realize we could do that with grep. It just takes each line as an additional pattern?

      Then after grep, you'd have a list of lines in stdout like

      Code:
      contig06610	Q9SQV1	GO:0000184	GO:0006139	GO:0006139	nucleobase, nucleoside, nucleotideandnucleicacidmetabolicprocess
      From there, awk to extract particular columns you wanted. I presume columns 3,4 and 5 for Gene Ontology?
      Last edited by ctseto; 11-14-2013, 12:11 PM.

      Comment

      • vivek_
        PhD Student
        • Jul 2012
        • 164

        #4
        for id in `cat second_file.txt`;do grep -w $id first_file.txt;done
        Even "Join" should be fine if both files are sorted by contig name.

        Comment

        • ckant
          Junior Member
          • Sep 2011
          • 5

          #5
          Thanks a lot Ryan, ctseto and vivek. .

          Comment

          Latest Articles

          Collapse

          • GATTACAT
            Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
            by GATTACAT
            Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
            07-01-2026, 11:43 AM
          • SEQadmin2
            Nine Things a Sample Prep Scientist Thinks About Before Sequencing
            by SEQadmin2


            I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.

            Here are nine questions we think about, in roughly the order they matter, before...
            06-18-2026, 07:11 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, 07-02-2026, 11:08 AM
          0 responses
          14 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-30-2026, 05:37 AM
          0 responses
          15 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-26-2026, 11:10 AM
          0 responses
          20 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-17-2026, 06:09 AM
          0 responses
          54 views
          0 reactions
          Last Post SEQadmin2  
          Working...