Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • StephaniePi83
    Member
    • Sep 2011
    • 52

    perl : Remove redundant feature in fasta file

    Hi,

    I have some trouble with removing redundant feature in a fasta file. I want to create an indexe for Bowtie.
    I have this file :
    Code:
    >pi1
    [B]ATGCGTGAAATGCAT[/B]
    >pi2
    TGCCCTGATAGGGACCAGTAGAC
    >pi3
    [B]ATGCGTGAAATGCAT[/B]A
    >pi4
    TGCATGACTA
    >pi5
    [B]ATGCGTGAAATGCAT[/B]AT
    But some feature have the same sequence but differ in length. I want to keep only the longer sequence. Finally, i would like to have a file like :
    Code:
    >pi2
    TGCCCTGATAGGGACCAGTAGAC
    >pi4
    TGCATGACTA
    >pi5
    [B]ATGCGTGAAATGCAT[/B]AT
    I don't know how i can do this ... maybe someone can help me ?

    Thanks in advance for your reply !
  • SES
    Senior Member
    • Mar 2010
    • 275

    #2
    I think PRINSEQ will do exactly what you are wanting. Take a look at the manual under the section about sequence duplications.

    Comment

    • weasteam
      Member
      • Dec 2008
      • 26

      #3
      here you go:
      Frontage Laboratories is a global pharmaceutical development organization (PDO) advancing drug discovery and development through integrated laboratory and clinical services.


      Code:
      #!/usr/bin/perl
      #	by Yonggan Wu
      #	[email][email protected][/email]
      #	Ocean Ridge Bioscience LLC
      #	Version 01 Date: 2012-02-16 15:01:08 
      #	Version 01 Updates: 
      #	Input file: a fasta file
      #	Output file: a unique fasta file
      #	System Requirements: linux, perl
      #	Usage: perl test.pl infile.fasta
      ################################################################################
      use strict;
      use warnings;
      #read the file into a hash
      my %seq;
      my $title;
      my $infile=shift or die "give me a infile\n"
      open (IN,"$infile");
      while (<IN>){
      	$_=~s/\n//;
      	$_=~s/\r//;
      	if ($_=~/>/){
      		$title=$_;
      		$title=~s/>//;
      	}
      	else{
      		$seq{$_}=$title;
      	}
      }
      close IN;
      #remove the abundant sequences
      my @seq=keys (%seq);
      my @uniqueseq;
      my $find=0;
      foreach (@seq){
      	$find=0;
      	my $seq=uc($_);
      	foreach (@uniqueseq){
      		if ($seq=~/$_/){
      			$_=$seq;#replace with longer seq
      			$find=1;
      		}
      		if ($_=~/$seq/){
      			$find=1;
      		}
      	}
      	if ($find==0){
      		push @uniqueseq,$seq;
      	}
      }
      #outout the final result
      open (OUT,">output.fasta");
      foreach (@uniqueseq){
      	print OUT ">$seq{$_}\n$_\n";
      }
      close OUT;

      Comment

      • StephaniePi83
        Member
        • Sep 2011
        • 52

        #4
        thanks a lot, it's exactly what i need !

        Comment

        • StephaniePi83
          Member
          • Sep 2011
          • 52

          #5
          I re open this thread because i solved the problem with the script bellow, but now, i have bigger file and it's time consuming.
          I try to solve my problem with PRINSEQ, with the following comand line, but it did'nt work, it only remove reads that have the exact same sequence
          perl prinseq-lite.pl -verbose -fasta tmp1.fa -derep 123 -out_format 1
          Someone is familiar with this tool ?
          Here is an example of what i would like to do :
          INPUT :
          >pi1
          AAAAAAAAAATTAAGGGCCAGCTGA
          >pi12
          AAAAAAAAAATTAAGGGCCAGCTGAA
          >pi13
          AAAAAAAAACTTGAACTCTACTGC
          >pi14
          AAAAAAAAATTAAGGGCCAGCTGAA
          >pi15
          AAAAAAAAATTTTGGATGATCTTAAT
          >pi16
          AAAAAAAAATTTTGGATGATCTTAATT
          >pi17
          AAAAAAAACAAGGTCGGCATAAAG
          >pi18
          AAAAAAAACGAACATGAGAGGATGGA
          OUTPUT :
          >pi12
          AAAAAAAAAATTAAGGGCCAGCTGAA
          >pi13
          AAAAAAAAACTTGAACTCTACTGC
          >pi16
          AAAAAAAAATTTTGGATGATCTTAATT
          >pi17
          AAAAAAAACAAGGTCGGCATAAAG
          >pi18
          AAAAAAAACGAACATGAGAGGATGGA
          Thanks in advance for your help !

          Comment

          • SES
            Senior Member
            • Mar 2010
            • 275

            #6
            The "1" in the argument
            Code:
            -derep 123
            to prinseq-lite.pl says to remove exact duplicates only. As I understand your question now, I don't think prinseq will actually do what you want. Have you tried the perl script posted by weastem above? I have not tested it but that may be a solution for you.

            Comment

            • StephaniePi83
              Member
              • Sep 2011
              • 52

              #7
              Yes i tested the script but it's really time consuming for my dataset; it is running since more than 24 hours ...

              Comment

              • StephaniePi83
                Member
                • Sep 2011
                • 52

                #8
                I re opened this thread because i have a similar problem.
                I have family of sequence sharing the same "motif" as in my example below :
                >a
                ACTTTCCACAACGATGGAAGATGATGA
                >b
                ACTTTCCACAACGATGGAAGATGATGAA
                >c
                ATTCCACAACGATGGAAGATGATGAA
                >d
                CTTTCCACAACGATGGAAGATGATGAA
                >e
                NTCCACAACGATGGAAGATGATGAAGA
                >f
                TACTTTCCACAACGATGGAAGATGATGA
                >g
                TACTTTCCACAACGATGGAAGATGATGAA
                >h
                TCCACAACGATGGAAGATGATGA
                I would like to get the smallest sequence sharing the motif, in my example :
                >h
                TCCACAACGATGGAAGATGATGA
                How can i do this ? is there any tools able to do this ?

                Comment

                • tomc
                  Member
                  • Feb 2011
                  • 29

                  #9
                  grep your sequence & sort results by length is a start

                  Comment

                  • gsgs
                    Senior Member
                    • Oct 2009
                    • 139

                    #10
                    Given a file with unaligned sequences s1...sm of different lengths.
                    You want to quickly identify sequences that are substrings of another one.
                    ----------------------------------------------------------
                    Compute and store sequence lengths.

                    Pick some random substrings t1,...,tk of suitable length l ,
                    k and l to be calculated from m and the lengths for optimal speed and memory usage.

                    For each (i,j) compute and store whether sequence si contains substring tj.
                    This can be calculated in one step, by going through all the sequences and letters.

                    Walk through the sequence pairs (i,j) and consider pairs only where each
                    substring covered by i is also covered by j and length(j)>=length(i)

                    These have then to be checked in detail then whether i is a substring of j,
                    but most pairs are quickly discarded and needn't be considered,
                    so I think this would be pretty fast.


                    {for the definitions of subsequence and substring see wikipedia}

                    Comment

                    Latest Articles

                    Collapse

                    • 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
                    • SEQadmin2
                      Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                      by SEQadmin2



                      Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                      There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                      07-08-2026, 05:17 AM
                    • GATTACAT
                      Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                      by GATTACAT
                      Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
                      07-01-2026, 11:43 AM

                    ad_right_rmr

                    Collapse

                    News

                    Collapse

                    Topics Statistics Last Post
                    Started by SEQadmin2, Today, 10:26 AM
                    0 responses
                    9 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 07-09-2026, 10:04 AM
                    0 responses
                    24 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 07-08-2026, 10:08 AM
                    0 responses
                    16 views
                    0 reactions
                    Last Post SEQadmin2  
                    Started by SEQadmin2, 07-07-2026, 11:05 AM
                    0 responses
                    33 views
                    0 reactions
                    Last Post SEQadmin2  
                    Working...