473,385 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

global search of motif

Hi all,

I was writing a code to find out the exact positions of different variants of a motif in a sequence. Therefore I have two arrays. One with the sequence and one with the different variants of the motif (e.g. small_motif_a CGTCGCACAGC). The problem is my output is completely senseless as it gives me positions that does not even lay in my sequence, and it finds only one position. There must be something wrong with the search in the loop...

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use Bio::Perl;
  4.  
  5. # This script will find the exact location of motifs in a DNA sequence
  6.  
  7. my $dnafilename;
  8. my $varfilename;
  9. my $refseq;
  10. my $pos;
  11. my $motif;
  12. my $refseqtemp;
  13. my @dna;
  14. my $dna;
  15. my @var;
  16. my $var;
  17. @var=();
  18. @dna=();
  19.  
  20.  
  21. print "Enter the filename of your input file with the sequence:= ";            # File that contains your DNA sequence
  22. chomp ($dnafilename=<STDIN>);
  23. open(DNAINPUT,'<',$dnafilename) or die ("$dnafilename Can not open file\n"); 
  24.  
  25. print "Enter the filename of your input file with the variants:= ";            # File that contains your different variants
  26. chomp ($varfilename=<STDIN>);
  27. open (VARINPUT,'<',$varfilename) or die ("$varfilename Can not open file\n");
  28.  
  29. @dna=<DNAINPUT>;                                    # stores the sequence in an array
  30. # print @dna;
  31.  
  32. while (<VARINPUT>) 
  33. {                                            # stores the variants in an array
  34.  chomp;
  35.  push @var, $_;
  36. }
  37.  
  38. $refseq= $dna[0];
  39. chomp $refseq;                                  
  40. $pos=0;                                            # position of the first base
  41.  
  42.  
  43. my $temp;
  44. $temp=1;
  45.  
  46. foreach my $thing (@var)
  47. {
  48.  $motif=$thing;
  49.  $refseqtemp = $refseq;                                 #start for every motif with the whole sequence
  50.  print "$motif\n";
  51.  $motif =~ s/^\w*\s//;
  52.  print "$motif\n";
  53.  while(length($refseq)>0 && $temp>0)                                # as long as there is a rest sequence (>0)
  54.   {
  55.   $temp=0;
  56.   my $length = length($refseq);
  57.   print "length now $length\n";
  58.  
  59.    if ($refseq=~ /($motif)/ig)                                # search for the motif (variant)
  60.    {
  61.         print "found\n";
  62.         $pos= $pos + length($')-1;
  63.         print "pos $pos\n";
  64.         $pos= $pos + length($&);
  65.     $refseq= $';
  66.         $dna=$dna+1;
  67.         $temp=1;
  68.     }
  69.  
  70. else {
  71.        print "Sorry, no match\n";
  72.      }
  73.   }
  74.  
  75.  
  76. }
  77.  
Maybe someone has an idea... any help appreciated

Cheers,
Anja
Oct 20 '10 #1
0 1195

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Tandem person | last post by:
I am in search of a free tool which can replace multiple strings on the particular directory . Please let me know if any such , written in perl. Thanks Athresh
1
by: Zenobia | last post by:
Hello I want a search & replace text in source code for several files in several directories. It would seem that both Dreamweaver MX 6 and GoLive 6 offer this feature but not for .aspx file...
4
by: RoadRunner | last post by:
Hi, I have a question. I am asked to produce a global search of a given corporate name, in more that one database. Each database has different table names and different field names in the tables....
2
by: egateway | last post by:
I have issues database that utilizes two forms. One for provides a read only issues/task list and another form for add/update of issues. I'd like to be able to add an search text box to the summary...
9
by: ARC | last post by:
I wrote a quick routine to search for the text "Mainmenu" in the MSysQueries table, in the expression field. I was able to find and alter all occurences of this phrase with the exception of 3: ...
1
by: John | last post by:
Hello, I was wondering if anyone had any tips for some software that will do a global search and replace for table names and field names in access (across a split db would be nice also). ...
2
by: HalfCoded | last post by:
Hi everyone, I am currently working at learning perl but come up with two problems i can't clear on my own. I use perl version 5.8 on windows xp The complete I am working on is supposed to...
6
by: simon.robin.jackson | last post by:
Ok. I need to develop a macro/vba code to do the following. There are at least 300 corrections and its expected for this to happen a lot more in the future. Therefore id like a nice...
0
by: simon.robin.jackson | last post by:
I can open the tables into Excel no problem and rekon i could macro/ vba it in excel a bit easier. However, this is a copy of the data I think? not the actual source data from the .mdb. Is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.