Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • Adding counting Contig number at the start of Fasta Sequences

    I am trying to add Prefix to a list of Fasta sequences (30K+ which I have de-novo assembled) in a fasta file at the same time.

    I know from the past that have been able to add it at the end of the sequences. But I am getting a bit confused on how should I do it for the start of the Fasta sequence.

    For the end of sequence.
    Code:
    awk '/^>/{$0=$0"_Contig_"(++i)}1' input_file.fasta > output_file.fasta
    This will change something like this in the fasta file:

    From:
    >Sequence_header
    ATAGCATA
    To:
    >Sequences_header_Contig_1
    ATAGCATA
    ...
    >Sequences_header_Contig_n
    ATAGCATA


    I hope to do something like this:

    >Sequence_header
    ATAGCATA
    To:
    >Contig_1_Sequences_header
    ATAGCATA
    ...
    >Contig_n_Sequences_header
    ATAGCATA


    Code:
    awk '/^>/{"Contig_"(++i)"_"$0=$0}1' input_file.fasta > output_file.fasta
    Unfortunately I receive a synthax error.

    If someone could kindly show what I am doing wrong. I would greatly appreciate it.

    Many thanks.
    Last edited by Zapages; 05-09-2015, 05:02 PM.

  • #2
    Sorry, I don't speak awk.
    Code:
    perl -pe 'next unless /^>/; $i++; s/>(\S+)/>Contig_${i}_$1/' input_file.fasta > output_file.fasta
    seems to work.

    --
    Phillip

    Comment


    • #3
      How about this?

      Code:
      $  awk '{if (/^>/) print ">Contig_"(++i)"_" substr($0,2); else print $0;}'  your_file > new_file

      Comment


      • #4
        Thank you Phillip and Genomax. Both of the strategies work.

        Really appreciate all the help.

        Many Thanks,

        Zapages

        Comment

        Latest Articles

        Collapse

        • seqadmin
          Recent Advances in Sequencing Analysis Tools
          by seqadmin


          The sequencing world is rapidly changing due to declining costs, enhanced accuracies, and the advent of newer, cutting-edge instruments. Equally important to these developments are improvements in sequencing analysis, a process that converts vast amounts of raw data into a comprehensible and meaningful form. This complex task requires expertise and the right analysis tools. In this article, we highlight the progress and innovation in sequencing analysis by reviewing several of the...
          Yesterday, 07:48 AM
        • seqadmin
          Essential Discoveries and Tools in Epitranscriptomics
          by seqadmin




          The field of epigenetics has traditionally concentrated more on DNA and how changes like methylation and phosphorylation of histones impact gene expression and regulation. However, our increased understanding of RNA modifications and their importance in cellular processes has led to a rise in epitranscriptomics research. “Epitranscriptomics brings together the concepts of epigenetics and gene expression,” explained Adrien Leger, PhD, Principal Research Scientist...
          04-22-2024, 07:01 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, Today, 06:57 AM
        0 responses
        9 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, Yesterday, 07:17 AM
        0 responses
        13 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 05-02-2024, 08:06 AM
        0 responses
        19 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-30-2024, 12:17 PM
        0 responses
        22 views
        0 likes
        Last Post seqadmin  
        Working...
        X