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
          Current Approaches to Protein Sequencing
          by seqadmin


          Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
          04-04-2024, 04:25 PM
        • seqadmin
          Strategies for Sequencing Challenging Samples
          by seqadmin


          Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
          03-22-2024, 06:39 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, 04-11-2024, 12:08 PM
        0 responses
        25 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 10:19 PM
        0 responses
        28 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 09:21 AM
        0 responses
        24 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-04-2024, 09:00 AM
        0 responses
        52 views
        0 likes
        Last Post seqadmin  
        Working...
        X