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
          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 on Modified Bases...
          Yesterday, 07:01 AM
        • 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

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, 04-11-2024, 12:08 PM
        0 responses
        39 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 10:19 PM
        0 responses
        41 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 09:21 AM
        0 responses
        35 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-04-2024, 09:00 AM
        0 responses
        55 views
        0 likes
        Last Post seqadmin  
        Working...
        X