Unconfigured Ad

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

    #1

    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

          • SEQadmin2
            Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
            by SEQadmin2



            Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

            Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
            ...
            10-14-2026, 09:55 AM
          • SEQadmin2
            New Genomics Technologies Take Aim at Long-Standing Limits
            by SEQadmin2


            Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

            We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
            ...
            09-28-2026, 10:25 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, 10-22-2026, 11:13 AM
          0 responses
          30 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-22-2026, 10:48 AM
          0 responses
          22 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-15-2026, 10:52 AM
          0 responses
          39 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-14-2026, 05:39 AM
          0 responses
          45 views
          0 reactions
          Last Post SEQadmin2  
          Working...