Unconfigured Ad

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

    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

          • GATTACAT
            Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
            by GATTACAT
            Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
            Yesterday, 11:43 AM
          • SEQadmin2
            Nine Things a Sample Prep Scientist Thinks About Before Sequencing
            by SEQadmin2


            I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.

            Here are nine questions we think about, in roughly the order they matter, before...
            06-18-2026, 07:11 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, Today, 11:08 AM
          0 responses
          6 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-30-2026, 05:37 AM
          0 responses
          11 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-26-2026, 11:10 AM
          0 responses
          18 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-17-2026, 06:09 AM
          0 responses
          53 views
          0 reactions
          Last Post SEQadmin2  
          Working...