Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #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


    • #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

      • seqadmin
        Best Practices for Single-Cell Sequencing Analysis
        by seqadmin



        While isolating and preparing single cells for sequencing was historically the bottleneck, recent technological advancements have shifted the challenge to data analysis. This highlights the rapidly evolving nature of single-cell sequencing. The inherent complexity of single-cell analysis has intensified with the surge in data volume and the incorporation of diverse and more complex datasets. This article explores the challenges in analysis, examines common pitfalls, offers...
        06-06-2024, 07:15 AM
      • seqadmin
        Latest Developments in Precision Medicine
        by seqadmin



        Technological advances have led to drastic improvements in the field of precision medicine, enabling more personalized approaches to treatment. This article explores four leading groups that are overcoming many of the challenges of genomic profiling and precision medicine through their innovative platforms and technologies.

        Somatic Genomics
        “We have such a tremendous amount of genetic diversity that exists within each of us, and not just between us as individuals,”...
        05-24-2024, 01:16 PM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by seqadmin, Yesterday, 06:58 AM
      0 responses
      13 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 06-06-2024, 08:18 AM
      0 responses
      20 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 06-06-2024, 08:04 AM
      0 responses
      18 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 06-03-2024, 06:55 AM
      0 responses
      13 views
      0 likes
      Last Post seqadmin  
      Working...
      X