Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akjones
    Member
    • Jun 2013
    • 24

    #1

    sort contigs based on fasta header

    Hello All,

    I have a problem that I am looking for some input on.

    I have been using the genome assembler SPAdes, which outputs assembled contigs as a fasta file. I would like to sort my contigs based on average coverage (i.e. remove contigs with low coverage), which sounds like it should be a fairly easy task. However, all of the coverage information is contained within the fasta sequence header itself, for example (taken from my assembly file):

    Code:
    >NODE_100_length_628_cov_0.818363_ID_199
    So the average coverage for this particular contig is .8.
    The fact that the information is contained within the header itself and is not in a table format prevents me from doing some sort of copy/paste sorting shenanigans in Excel. So I figured I could write something up in Perl and use regular expression to sort based on the value of the numbers following
    Code:
    cov_
    . But I ran into some issues with that, likely because I am a beginner and I still don't really know what I'm doing. I know I need to use BioPerl for the sequence/multifasta handling, and I know I need to restrict the matching to the header only and not the sequence itself, and then I need a way to delete all sequences with headers that do not meet a certain value (e.g. all values less than 10).

    I've done some research via the almighty Google and come across people trying to complete similar tasks, but in all of the cases I found the individuals knew the EXACT header/sequence name of the sequence they wanted to extract. These methods are not very applicable to me since I am looking to sort sequences based on whether or not they meet a specific condition.

    Any input or advice to lead me in the right direction would be greatly appreciated. So far all my code does is read the input file *golf clap*
    I also know that because my file is relatively large (4MB) it is not efficient to have a script that reads everything line by line, but I'm not sure what else to do or how to address that issue.

    Please help! And thanks in advance,

    ~Ana
  • westerman
    Rick Westerman
    • Jun 2008
    • 1104

    #2
    4MB is not a large file. Reading line by line would be fine. However your code was not enclosed in your post thus it is hard to say what is wrong with it.

    Comment

    • akjones
      Member
      • Jun 2013
      • 24

      #3
      Sorry, it wasn't enclosed because as of right now it doesn't do anything other than read the file, so I didn't think posting it would be helpful. I don't know how to go about solving the other problems I stated in my question which is why I asked for input. But since you asked here it is:

      Code:
      use Bio::SeqIO;
      
      $seqio_obj = Bio::SeqIO->new (-file =>"/Users/annaliesejones/Desktop/Assembly6contigs.fasta", -format => "fasta" );
      
      while($seq_obj = $seqio_obj->next_seq) {
      
      print $seq_obj->seq;
      
      }
      Even that doesn't work well, it prints all sequences together without a newline or the fasta header. But that's not really the point, I just wanted to see if I could read the file.

      And now I'm stuck.

      Comment

      • westerman
        Rick Westerman
        • Jun 2008
        • 1104

        #4
        1) Use a newline after printing ... e.g., 'print $seq_obj->seq . "\n" ' ... many ways to do this.

        2) Look at $seq_obj->display for your header information. From there you can use a regexp to pull out the information; e.g.,
        Code:
        (my $coverage) = $seq_obj->display =~ m/_cov_(.+)_ID/;

        Comment

        Latest Articles

        Collapse

        • kinpict.com
          Reply to 16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
          by kinpict.com
          The part about this topic feels surprisingly grounded, and the details on the page is the bit that made me slow down. I’d keep <a href="https://kinpict.com/">ai family photo generator</a> bookmarked for later.
          Today, 06:37 PM
        • SEQadmin2
          16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
          by SEQadmin2





          NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification,...
          10-30-2026, 06:46 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, 11-12-2026, 07:59 AM
        0 responses
        27 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 11-05-2026, 09:25 AM
        0 responses
        35 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 11-03-2026, 11:54 AM
        2 responses
        56 views
        0 reactions
        Last Post kinpict.com  
        Started by SEQadmin2, 10-28-2026, 09:57 AM
        0 responses
        175 views
        0 reactions
        Last Post SEQadmin2  
        Working...