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
          Advanced Tools Transforming the Field of Cytogenomics
          by seqadmin


          At the intersection of cytogenetics and genomics lies the exciting field of cytogenomics. It focuses on studying chromosomes at a molecular scale, involving techniques that analyze either the whole genome or particular DNA sequences to examine variations in structure and behavior at the chromosomal or subchromosomal level. By integrating cytogenetic techniques with genomic analysis, researchers can effectively investigate chromosomal abnormalities related to diseases, particularly...
          09-26-2023, 06:26 AM
        • seqadmin
          How RNA-Seq is Transforming Cancer Studies
          by seqadmin



          Cancer research has been transformed through numerous molecular techniques, with RNA sequencing (RNA-seq) playing a crucial role in understanding the complexity of the disease. Maša Ivin, Ph.D., Scientific Writer at Lexogen, and Yvonne Goepel Ph.D., Product Manager at Lexogen, remarked that “The high-throughput nature of RNA-seq allows for rapid profiling and deep exploration of the transcriptome.” They emphasized its indispensable role in cancer research, aiding in biomarker...
          09-07-2023, 11:15 PM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, Today, 07:14 AM
        0 responses
        6 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 09-29-2023, 09:38 AM
        0 responses
        13 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 09-27-2023, 06:57 AM
        0 responses
        13 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 09-26-2023, 07:53 AM
        0 responses
        30 views
        0 likes
        Last Post seqadmin  
        Working...
        X