Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SeqTroubles
    Member
    • Sep 2016
    • 20

    #1

    extract fasta sequences from multifasta file using partial or gene names

    Hi All,

    I am working PROKKA v1.12 files. I have a list of gene names such as

    sacX
    arcB
    metB
    sprT
    adrB_2
    fadD

    and my fasta file is like so

    >BOKHJPML_00001 hypothetical protein
    ATGC
    >BOKHJPML_00002 hypothetical protein
    ATGC
    >BOKHJPML_00003 Protease HtpX
    ATGC
    >BOKHJPML_00006 ATP-dependent Clp protease ATP-binding subunit ClpC
    ATGC
    BOKHJPML_00016 Inner membrane protein YfdC
    ATGC

    I want to extract the fasta sequences from the list. I have tried following previous suggestions using faidhttps://www.biostars.org/p/126204/x and biopyhttps://www.biostars.org/p/2822/thon
    With no success. This faidx example is the closest I have come to success but I get a string of errors

    warning: sacX not found in file
    warning: arcB not found in file
    warning: metB not found in file
    warning: sprT not found in file
    warning: adrB_2 not found in file
    warning: fadD not found in file

    Thanks in advance
  • GenoMax
    Senior Member
    • Feb 2008
    • 7142

    #2
    One way would be to extract the full read headers from the sequence file using your ID's.
    Code:
    for i in `cat ./id_file `; do grep -i $i sequence.fa >> ID_in_sequence_file;done
    Then use one of the methods you have found or faSomeRecords utility from Jim Kent to get the sequences extracted.

    Comment

    • Brian Bushnell
      Super Moderator
      • Jan 2014
      • 2709

      #3
      You can also use BBMap's filterbyname.sh tool, particularly if you have a long list of names:

      Code:
      filterbyname.sh in=file.fa out=filtered.fa include=t names=names.txt substring
      The "substring" flag allows partial matches.

      Comment

      • SeqTroubles
        Member
        • Sep 2016
        • 20

        #4
        Originally posted by Brian Bushnell View Post
        You can also use BBMap's filterbyname.sh tool, particularly if you have a long list of names:

        Code:
        filterbyname.sh in=file.fa out=filtered.fa include=t names=names.txt substring
        The "substring" flag allows partial matches.
        Thanks so much Brian, this is very straight forward. Just a quick question about the tool. My gene name list contains some ambiguous names such as group_XXXX, as it is an output of roary. Would setting substring=t or substring=names cause it to partially match fasta headers from prokka output via the locus tag? If so is there a way to prevent this I have been using the following command:

        Code:
        filterbyname.sh in=seqs.ffn out=test.fasta include=t names=list.txt substring=name casesensitive=f
        There are some seqs on my output which I feel should not be present. Although I do think the casesensitive flag is most likely the culprit?
        Thanks.

        Comment

        • Brian Bushnell
          Super Moderator
          • Jan 2014
          • 2709

          #5
          "substring=names" will consider a sequence to be a match if the sequence name contains any line in list.txt as a substring; and in this case, it's ignoring case. I suggest not ignoring case unless it's essential. Note that if you have any really short names in your file, like "A", it might match just about everything...

          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, Today, 11:13 AM
          0 responses
          12 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, Today, 10:48 AM
          0 responses
          11 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-15-2026, 10:52 AM
          0 responses
          32 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-14-2026, 05:39 AM
          0 responses
          40 views
          0 reactions
          Last Post SEQadmin2  
          Working...