Header Leaderboard Ad

Collapse

script suggestion (SAM file)

Collapse

Announcement

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

  • script suggestion (SAM file)

    Hi everyone!
    In this attached example, i would like to know how many times the element
    "bta-miR-191" and "bta-miR-10" in the header of a SAM file is repeated in the rest of
    the document (in this case: 6 and 5 respectively).

    Could you give me an idea for an script based on this example?

    Thanks
    Attached Files

  • #2
    grep -v '@SQ' example.txt | awk '{if ($3=="bta-miR-191") print}' | wc -l


    grep -v '@SQ' example.txt | awk '{if ($3=="bta-miR-10") print}' | wc -l

    Comment


    • #3
      Hello- To expand a bit shoegame2001's answer... If your input file is big you might want to read thorough it only once and count the two (or more) patterns at the same time:

      Code:
      grep -v '@SQ' example.txt \
      | awk '{if ($3=="bta-miR-191")
                  mir191+=1;
              else if ($3 == "bta-miR-10")
                  mir10+=1}
              END {print "bta-miR-191:" mir191, "\nbta-miR-10:", mir10}'
      Dario

      Comment


      • #4
        thanks, the grep function was very usufull to remove the headers.
        After doing that, i did a count ot he repited elements on column 3.
        cat myfile-noheaders.out | awk '{print$3}' | sort | uniq -c | sort -rnk1 >SAM-counts.out

        I hope this can be helpfull for somebody else!

        Comment


        • #5
          if it is usefull, here the complete script to remove the headers ('@') and then count repeated terms in column 3 of the SAM file:

          grep -v '@' myfile.out | awk '{print$3}' | sort | uniq -c | sort -rnk1 >SAM-counts.out

          Cheeers

          Comment

          Latest Articles

          Collapse

          • seqadmin
            Targeted Sequencing: Choosing Between Hybridization Capture and Amplicon Sequencing
            by seqadmin




            Targeted sequencing is an effective way to sequence and analyze specific genomic regions of interest. This method enables researchers to focus their efforts on their desired targets, as opposed to other methods like whole genome sequencing that involve the sequencing of total DNA. Utilizing targeted sequencing is an attractive option for many researchers because it is often faster, more cost-effective, and only generates applicable data. While there are many approaches...
            03-10-2023, 05:31 AM
          • seqadmin
            Expert Advice on Automating Your Library Preparations
            by seqadmin



            Using automation to prepare sequencing libraries isn’t a new concept, and most researchers are aware that there are numerous benefits to automating this process. However, many labs are still hesitant to switch to automation and often believe that it’s not suitable for their lab. To combat these concerns, we’ll cover some of the key advantages, review the most important considerations, and get real-world advice from automation experts to remove any lingering anxieties....
            02-21-2023, 02:14 PM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, 03-17-2023, 12:32 PM
          0 responses
          8 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 03-15-2023, 12:42 PM
          0 responses
          17 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 03-09-2023, 10:17 AM
          0 responses
          66 views
          1 like
          Last Post seqadmin  
          Started by seqadmin, 03-03-2023, 12:03 PM
          0 responses
          64 views
          0 likes
          Last Post seqadmin  
          Working...
          X