Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • how to remove sequences with 0 and * from fast

    Dear all

    My fasta file contains thousands of sequences, and it looks like this:
    >r1624.1
    *
    >r1624.2
    *
    >r1625.2
    GAAGGAAATACTACCCAGTATCCTTCGTTGGCCCAACGTTCCAGTACATGCAGGCTAATAACTATTACCCAG
    >r1625.1
    AGCACGATTAAAGAGTAGCTACTTAAAAACCTAATCAAAATTATTTCATCTCTGGTGATTATCACTAGAAAT
    >r1626.1
    ATTTGCAACTACCACTTGGCCACTCAGGATGATTTGCAAAACGCAGTGAACGTCATGTGGAGTAGAGACCTC
    >r1626.2
    TCTGACATAAGGGACTTGTATGCTTACGAGGAAGAGGCCATGGAGCAGGGCATTTCAAACTATATTGAGTCA
    >r1627.1
    *
    >r1627.2
    *
    >r1641.1
    0
    >r1641.2
    0
    >r1643.1
    0
    >r1643.2
    0
    how to remove those sequences with 0 and * ?

    Many thanks

  • #2
    cat file.fa | awk '{if ((p%2)==0) s=$0;else if (($1!="0")&&($1!="*")) printf "%s\n%s\n",s,$0; p++}'

    Comment


    • #3
      dont need cat for awk to work

      awk 'BEGIN{i=0}{if(i==0){hdr=$0; i++}else{if(($0!="*")&&($0!="0"))print hdr"\n"$0; i=0}}' <in.fasta >out.fasta

      Comment


      • #4
        I win the "Useless use of cat award" ! ( http://partmaps.org/era/unix/award.html ). There's also a built-in line counter variable in awk which I didn't use so I guess I just had a bad idiom day.

        Comment

        Latest Articles

        Collapse

        • seqadmin
          Recent Advances in Sequencing Analysis Tools
          by seqadmin


          The sequencing world is rapidly changing due to declining costs, enhanced accuracies, and the advent of newer, cutting-edge instruments. Equally important to these developments are improvements in sequencing analysis, a process that converts vast amounts of raw data into a comprehensible and meaningful form. This complex task requires expertise and the right analysis tools. In this article, we highlight the progress and innovation in sequencing analysis by reviewing several of the...
          05-06-2024, 07:48 AM
        • 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...
          04-22-2024, 07:01 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, Yesterday, 07:03 AM
        0 responses
        15 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 05-10-2024, 06:35 AM
        0 responses
        37 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 05-09-2024, 02:46 PM
        0 responses
        43 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 05-07-2024, 06:57 AM
        0 responses
        39 views
        0 likes
        Last Post seqadmin  
        Working...
        X