Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • Remove N's and split contigs

    Hi,

    I have some genomes that I will be uploading to NCBI soon. I have been told that all N's need to be removed and the contigs split at this position.

    I am new to command line interface so I was hoping someone could recommend a program and simple script that could do this for me. I would like to remove all N's and then split the contig at the location of the N's results in two new contigs. For example

    Contig 1: ATCGGATAANNNNNNNNNATCGCCGAT

    Contig 1.1: ATCGGATAA

    Contig 1.2 ATCGCCGAT


    Thanks!

  • #2
    perl -ne 'if($_ =~ /([^N]+)N+([^N]+)/){print $1;print stderr $1}' input.seq >contig1.txt 2>contig2.txt

    It will split the input file (input.seq) into contig1.txt and contig2.txt

    Comment


    • #3
      should that be

      Code:
      print stderr $2

      Comment


      • #4
        Thanks for that!!

        Will this rename the contigs?

        Will the contig that is split be called the same thing in contig1.txt and contig2.txt.

        Is it possible to rename the contigs when they are split. For example, if contig 84 is split into two contigs can they be renamed contig 84.1 and contig 84.2 for each half, respectively?

        Comment


        • #5
          mastal: you are right!
          Dagga: This script does not handle the contig names, only sequences, because you do not tell us what kind of input format do you have.
          Last edited by TiborNagy; 02-18-2014, 05:42 AM.

          Comment


          • #6
            TiborNagy: Sorry, the file will be in fasta format post de novo assembly.

            would you be able to alter the script to handle contig names please?

            Thanks!

            Comment


            • #7
              If you are doing your assemblies with velvet, setting '-scaffolding no' will stop velvet from joining contigs together with stretches of Ns.

              Comment


              • #8
                Excellent!

                Whilst this does help with some genomes that I am assembling right now, we have some older genomes that were sequenced by BGI and these contain N's that we still need to have removed...

                Comment


                • #9
                  Just for you :-)
                  Code:
                  #!/usr/bin/perl
                  
                  $seq = "";
                  
                  while(<>){
                     chomp;
                  
                     if(/^>/){
                        if($seq ne ""){
                           if($seq =~ /([^N]+)N+([^N]+)/){
                              print  "$id.1\n$1\n";
                              print STDERR "$id.2\n$2\n";
                           }
                        }
                        $seq = "";
                        $id = $_;
                     }
                     else{
                        $seq .= $_;
                     }
                  }
                  
                  if($seq =~ /([^N]+)N+([^N]+)/){
                    print "$id.1\n$1\n";
                    print STDERR "$id.2\n$2\n";
                  }

                  Comment


                  • #10
                    Thanks!! I appreciate it!

                    Comment

                    Latest Articles

                    Collapse

                    • seqadmin
                      Recent Developments in Metagenomics
                      by seqadmin





                      Metagenomics has improved the way researchers study microorganisms across diverse environments. Historically, studying microorganisms relied on culturing them in the lab, a method that limits the investigation of many species since most are unculturable1. Metagenomics overcomes these issues by allowing the study of microorganisms regardless of their ability to be cultured or the environments they inhabit. Over time, the field has evolved, especially with the advent...
                      09-23-2024, 06:35 AM
                    • seqadmin
                      Understanding Genetic Influence on Infectious Disease
                      by seqadmin




                      During the COVID-19 pandemic, scientists observed that while some individuals experienced severe illness when infected with SARS-CoV-2, others were barely affected. These disparities left researchers and clinicians wondering what causes the wide variations in response to viral infections and what role genetics plays.

                      Jean-Laurent Casanova, M.D., Ph.D., Professor at Rockefeller University, is a leading expert in this crossover between genetics and infectious...
                      09-09-2024, 10:59 AM

                    ad_right_rmr

                    Collapse

                    News

                    Collapse

                    Topics Statistics Last Post
                    Started by seqadmin, 10-02-2024, 04:51 AM
                    0 responses
                    13 views
                    0 likes
                    Last Post seqadmin  
                    Started by seqadmin, 10-01-2024, 07:10 AM
                    0 responses
                    21 views
                    0 likes
                    Last Post seqadmin  
                    Started by seqadmin, 09-30-2024, 08:33 AM
                    0 responses
                    25 views
                    0 likes
                    Last Post seqadmin  
                    Started by seqadmin, 09-26-2024, 12:57 PM
                    0 responses
                    18 views
                    0 likes
                    Last Post seqadmin  
                    Working...
                    X