Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • heso
    Member
    • May 2014
    • 19

    #1

    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?
  • scami
    Member
    • Sep 2010
    • 55

    #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

    • snf
      Junior Member
      • Oct 2014
      • 6

      #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

      • JackieBadger
        Senior Member
        • Mar 2009
        • 385

        #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

        • heso
          Member
          • May 2014
          • 19

          #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

          • SEQadmin2
            Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
            by SEQadmin2



            Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

            Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
            ...
            10-14-2026, 09:55 AM
          • SEQadmin2
            New Genomics Technologies Take Aim at Long-Standing Limits
            by SEQadmin2


            Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

            We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
            ...
            09-28-2026, 10:25 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, 10-15-2026, 10:52 AM
          0 responses
          25 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-14-2026, 05:39 AM
          0 responses
          31 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-13-2026, 09:56 AM
          0 responses
          28 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-09-2026, 11:14 AM
          0 responses
          28 views
          0 reactions
          Last Post SEQadmin2  
          Working...