Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shashankgupta
    Member
    • Feb 2015
    • 35

    #1

    rename mutiple fasta header for mutiple fasta files

    Hi,

    I have mutiple fasta file and I want to change the header, for this I am using -

    awk '/^>/{print ">C1_" ++i; next}{print}' C1_pandaseq.fasta > C1_pandaseq_new.fasta

    input fasta-
    >M03419:60:656544:1:1101:25150:3877:1
    CCTACGGGTGGCTGCAGTGGGGAATTTTGGACAA
    >M03419:60:656544:1:1101:8498:4267:1
    ACTACGGGAGGCAGCAGGGGGGAATTTTGGACAATGGAAACCAGGG
    >M03419:60:656544:1:1101:7884:4445:1
    CCTACGGGTGGCAGCAGTGGGGAATATTGGACAATGCAACCCTGATCCAGC

    output fasta-
    >C1_1
    CCTACGGGTGGCTGCAGTGGGGAATTTTGGACAAAAAAAAAAAAAAAA
    >C1_2
    ACTACGGGAGGCAGCAGGGGGGAATTTTGGACAATGGAAACCAGGG
    >C1_3
    CCTACGGGTGGCAGCAGTGGGGAATATTGGACAATGCAACCCTGATCCAGC


    Similarly i have mutiple fasta file, which looks like-
    C2_pandaseq.fasta
    C4_pandaseq.fasta
    C5_pandaseq.fasta
    C8_pandaseq.fasta
    T2_pandaseq.fasta
    T7_pandaseq.fasta

    So I need to rename all the fasta file header, e.g.,

    for fasta file C2_pandaseq.fasta
    >C2_1
    AAAAAAAAAAAAAAAAAAAAAAA
    >C2_2
    ATTTTGGGGGGGGCCCCCCCGGGGGGGA


    for fasta file C4_pandaseq.fasta
    >C4_1
    AAAAAAAAAAAAAAAAAAAAAAA
    >C4_2
    ATTTTGGGGGGGGCCCCCCCGGGGGGGA


    and so on...

    For each fasta file, i need to rename fasta header according to the file name only. Therefore, I need to write a for loop for this, but i dont know how can i do that.

    Any help.
    Thanks
  • wdecoster
    Member
    • Oct 2015
    • 97

    #2
    I would try something like:
    Code:
    for file in *_pandaseq.fasta
    do
    newname=$(echo $file |  sed s/_pandaseq.fasta//)
    awk '/^>/{print $newname ++i; next}{print}' $file > ${newname}_pandaseq_new.fasta
    done

    Comment

    • shashankgupta
      Member
      • Feb 2015
      • 35

      #3
      Originally posted by wdecoster View Post
      I would try something like:
      Code:
      for file in *_pandaseq.fasta
      do
      newname=$(echo $file |  sed s/_pandaseq.fasta//)
      awk '/^>/{print $newname ++i; next}{print}' $file > ${newname}_pandaseq_new.fasta
      done
      I have tried above for loop, but its not working.


      The output I got looks like -

      0
      CCTACGGGTGGCTGCAGTGGGGAATTTTGG
      0
      ACTACGGGAGGCAGCAGGGGGGAATTTTGGACA

      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, Yesterday, 10:35 AM
      0 responses
      7 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 08-06-2026, 07:41 AM
      0 responses
      26 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 08-03-2026, 10:13 AM
      0 responses
      45 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 07-31-2026, 02:55 AM
      0 responses
      48 views
      0 reactions
      Last Post SEQadmin2  
      Working...