i wrote a script that given a sequence extracts a 'n' dimension hashtable of oligos, and tells how many times and where a certain oligo is located.
I want to insert from keyboard an oligo and extract the positions, but ican't write it down. Any suggestions?
Thank you very much!
That's my script, that when asked to insert query returns the name of the file i opened first....
use strict;
my $f;
my $nomefile;
my $line;
my %oligo = ();
my %pos = ();
my $piece;
my $query;
my $sequenza;
my $i;
$nomefile = $ARGV[0];
open $f, "< $nomefile" or die "cannot open $nomefile: $!";
$sequenza = <$f>;
while($line = <$f>)
{
chomp($line);
if(substr($line, 0, 1) ne ">")
{
$sequenza = $sequenza.$line;
}
}
$sequenza = uc $sequenza;
for($i = 0; $i < length($sequenza) - 4; $i++)
{
$piece = substr($sequenza, $i, 4);
if(exists $oligo{$piece})
{
$oligo{$piece} = $oligo{$piece} + 1;
push(@{$pos{$piece}} , $i + 1);
}
else
{
$oligo{$piece} = 1;
push(@{$pos{$piece}} , $i + 1);
}
}
foreach $piece (sort keys %oligo)
{
print("$piece\t$oligo{$piece}\t@{$pos{$piece}}\n");
}
print("Insert query:\n");
$query = <>;
chomp($query);
$query = uc $query;
if(exists $oligo{$query})
{
print("$query\t compare $oligo{$query} volte\t in posizione @{$pos{$q
+uery}}\n");
}
else
{
print("$query does not appear in the sequence");
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.