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
            Beyond CRISPR/Cas9: Understand, Choose, and Use the Right Genome Editing Tool
            by SEQadmin2



            CRISPR/Cas9 sparked the gene editing revolution for both research and therapeutics.1 But this system still showed severe issues that limited its applications. The most prominent were the heavy reliance on PAM sequences, delivery limitations, double-stranded breaks that prompt unintended edits and cell death, and editing inefficiency (both in targeting and in knock-in reliability).

            Despite this, “CRISPR helped turn genome editing from a specialized technique into
            ...
            07-31-2026, 11:01 AM
          • SEQadmin2
            Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
            by SEQadmin2


            Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

            The systematic characterization of the human proteome has
            ...
            07-20-2026, 11:48 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, 08-06-2026, 07:41 AM
          0 responses
          14 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 08-03-2026, 10:13 AM
          0 responses
          31 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 07-31-2026, 02:55 AM
          0 responses
          40 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 07-24-2026, 12:17 PM
          0 responses
          26 views
          0 reactions
          Last Post SEQadmin2  
          Working...