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
            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, Yesterday, 12:08 PM
          0 responses
          11 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-10-2024, 10:19 PM
          0 responses
          17 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-10-2024, 09:21 AM
          0 responses
          14 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-04-2024, 09:00 AM
          0 responses
          43 views
          0 likes
          Last Post seqadmin  
          Working...
          X