473,389 Members | 1,094 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,389 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;
  5. # This script will find the exact location of motifs in a DNA sequence
  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=();
  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"); 
  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");
  29. @dna=<DNAINPUT>;                                    # stores the sequence in an array
  30. # print @dna;
  32. while (<VARINPUT>) 
  33. {                                            # stores the variants in an array
  34.  chomp;
  35.  push @var, $_;
  36. }
  38. $refseq= $dna[0];
  39. chomp $refseq;                                  
  40. $pos=0;                                            # position of the first base
  43. my $temp;
  44. $temp=1;
  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";
  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.     }
  70. else {
  71.        print "Sorry, no match\n";
  72.      }
  73.   }
  76. }
Maybe someone has an idea... any help appreciated

Oct 20 '10 #1
0 1196

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

Similar topics

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
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...
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....
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...
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: ...
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). ...
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...
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...
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...
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,...
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
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: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.