Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • reformatting a FASTA file

    Hi,
    I need to process my miRNA fasta file to end up with a collapsed fasta (read count format).
    I have used fastx_collapser for this task, that gives me the following output:

    >1-327278
    CGCGACCTCAGATCAGACGT
    >2-226606
    TATTGCACTTGTCCCGGCCTGT
    >3-206069
    GAAGCGGGTGCTCTTATTTT

    ....etc.

    However, I would need this file to be formatted as follows:

    CGCGACCTCAGATCAGACGT 327278
    TATTGCACTTGTCCCGGCCTGT 226606
    GAAGCGGGTGCTCTTATTTT 206069

    ....etc.

    so its sequence, followed by a tab and read count number. I need this format, since I'm going to feed the file in a subsequent analysis program.

    Is there any way to collapse a fasta file and get the output in a desired format?
    Or maybe somebody could suggest a simple way of reformatting the fastx_collapser file?

  • #2
    Hi there,

    If you are familiar with programming you could write a simple script. ALternatively you can open the fasta file with a text editor under linux and try this:
    1) Find and replace \nA with \t
    2) Find and replace \nG with \t
    3) Find and replace \nC with \t
    4) Find and replace \nT with \t
    5) repeat the step if you have sequences starting with non canonical bases (e.g. N or X ecc.)

    this will give you the following output:
    >1-327278 CGCGACCTCAGATCAGACGT
    >2-226606 TATTGCACTTGTCCCGGCCTGT
    >3-206069 GAAGCGGGTGCTCTTATTTT

    Then save the file and open it with excel while giving a separator the TAB and the "-" character. Invert the columns in the order you need and save as a tab formatted text file.

    Comment


    • #3
      awk -F "-" 'NR % 2 {tmp = $2} !(NR % 2) {printf "%s\t%s\n", $0, tmp}' test

      CGCGACCTCAGATCAGACGT 327278
      TATTGCACTTGTCCCGGCCTGT 226606
      GAAGCGGGTGCTCTTATTTT 206069

      note that this will fail if there is anything else in the file other than the lines indicated above.
      Last edited by snf; 10-30-2014, 10:36 AM. Reason: update

      Comment


      • #4
        Upload your data to Galaxy https://usegalaxy.org
        Use FASTA manipulation to convert from FASTA to tabular.

        You may then need to use the Text Manipulation tool to rearrange your columns.

        Comment


        • #5
          Thank you for all the answers.
          I tried out awk and it worked perfectly. Thanks again, I could not have figured it out myself

          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