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

          • kinpict.com
            Reply to 16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
            by kinpict.com
            The part about this topic feels surprisingly grounded, and the details on the page is the bit that made me slow down. I’d keep <a href="https://kinpict.com/">ai family photo generator</a> bookmarked for later.
            Today, 06:37 PM
          • SEQadmin2
            16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
            by SEQadmin2





            NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification,...
            10-30-2026, 06:46 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, 11-12-2026, 07:59 AM
          0 responses
          27 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 11-05-2026, 09:25 AM
          0 responses
          35 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 11-03-2026, 11:54 AM
          2 responses
          56 views
          0 reactions
          Last Post kinpict.com  
          Started by SEQadmin2, 10-28-2026, 09:57 AM
          0 responses
          175 views
          0 reactions
          Last Post SEQadmin2  
          Working...