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

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, 06-05-2026, 10:09 AM
          0 responses
          14 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-04-2026, 08:59 AM
          0 responses
          24 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-02-2026, 12:03 PM
          0 responses
          31 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 06-02-2026, 11:40 AM
          0 responses
          23 views
          0 reactions
          Last Post SEQadmin2  
          Working...