Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dagga
    Member
    • Feb 2014
    • 20

    #1

    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!
  • TiborNagy
    Senior Member
    • Mar 2010
    • 329

    #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

    • mastal
      Senior Member
      • Mar 2009
      • 666

      #3
      should that be

      Code:
      print stderr $2

      Comment

      • Dagga
        Member
        • Feb 2014
        • 20

        #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

        • TiborNagy
          Senior Member
          • Mar 2010
          • 329

          #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

          • Dagga
            Member
            • Feb 2014
            • 20

            #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

            • mastal
              Senior Member
              • Mar 2009
              • 666

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

              Comment

              • Dagga
                Member
                • Feb 2014
                • 20

                #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

                • TiborNagy
                  Senior Member
                  • Mar 2010
                  • 329

                  #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

                  • Dagga
                    Member
                    • Feb 2014
                    • 20

                    #10
                    Thanks!! I appreciate it!

                    Comment

                    Latest Articles

                    Collapse

                    • SEQadmin2
                      Beyond CRISPR/Cas9: Understand, Choose, and Use the Right Genome Editing Tool
                      by SEQadmin2



                      CRISPR/Cas9 sparked the gene editing revolution for both research and therapeutics.1 But this system still showed severe issues that limited its applications. The most prominent were the heavy reliance on PAM sequences, delivery limitations, double-stranded breaks that prompt unintended edits and cell death, and editing inefficiency (both in targeting and in knock-in reliability).

                      Despite this, “CRISPR helped turn genome editing from a specialized technique into
                      ...
                      Yesterday, 11:01 AM
                    • SEQadmin2
                      Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
                      by SEQadmin2


                      Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

                      The systematic characterization of the human proteome has
                      ...
                      07-20-2026, 11:48 AM
                    • SEQadmin2
                      Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                      by SEQadmin2



                      Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                      ...
                      07-09-2026, 11:10 AM

                    ad_right_rmr

                    Collapse

                    News

                    Collapse

                    Topics Statistics Last Post
                    Started by SEQadmin2, Yesterday, 02:55 AM
                    0 responses
                    8 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 07-24-2026, 12:17 PM
                    0 responses
                    12 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 07-23-2026, 11:41 AM
                    0 responses
                    12 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 07-20-2026, 11:10 AM
                    0 responses
                    24 views
                    0 reactions
                    Last Post SEQadmin2  
                    Working...