how to calculate the uncover region
I have some segments start and end position on a reference sequence, I
want to calculate the uncoverage region for the reference;
for example: reference sequence length= 100,
name [start,end]
segment 1 [1,20]
segment 2 [2,28]
segment 3 [50,100]
segment 4 [5,38]
so uncover region = [38,49]
now I already have %pos{start}=end structure for those segment
position, could somebody give a good method?
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: how to calculate the uncover region
Hi Lemon,
On Tue, 13 Sep 2011 04:54:40 -0700 (PDT)
Lemon <lemon027 [at] gmail.com> wrote:
> I have some segments start and end position on a reference sequence, I
> want to calculate the uncoverage region for the reference;
>
> for example: reference sequence length=3D 100,
>
> name [start,end]
> segment 1 [1,20]
> segment 2 [2,28]
> segment 3 [50,100]
> segment 4 [5,38]
>
> so uncover region =3D [38,49]
>
>
> now I already have %pos{start}=3Dend structure for those segment
> position, could somebody give a good method?
>
I suggest you merge overlapping segments into big meta-segments using a sor=
ted
array, one by one, and then see the uncovered regions between two adjacent
meta-segments.
Regards,
Shlomi Fish
--
------------------------------------------------------------ -----
Shlomi Fish http://www.shlomifish.org/
Rethinking CPAN - http://shlom.in/rethinking-cpan
<Botje> Khisanth =3D~ s/must sleep/must give Botje all my money/ .
=E2=80=94 Freenode=E2=80=99s #perl
Please reply to list if it's a mailing list post - http://shlom.in/reply .
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: how to calculate the uncover region
On Tue, 13 Sep 2011 04:54:40 -0700, Lemon wrote:
> I have some segments start and end position on a reference sequence, I
> want to calculate the uncoverage region for the reference;
>
> for example: reference sequence length=3D 100,
>
> name [start,end]
> segment 1 [1,20]
> segment 2 [2,28]
> segment 3 [50,100]
> segment 4 [5,38]
>
> so uncover region =3D [38,49]
>
>
> now I already have %pos{start}=3Dend structure for those segment positi=
on,
> could somebody give a good method?
By the usual definition the uncovered region is [39,49]. Here's an
approach:
$ cat differ
#!/usr/local/bin/perl
use strict;
use warnings;
use Set::IntSpan; # http://search.cpan.org/perldoc?Set%3A%3AIntSpan
my ($diff, [at] sets) =3D map { Set::IntSpan->new( $_ ) }
qw(1-100 1-20 2-28 50-100 5-38);
$diff -=3D $_ for [at] sets;
print "$diff\n";
$ ./differ
39-49
--
Peter Scott
http://www.perlmedic.com/ http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=3D0137001274
http://www.oreillyschool.com/certificates/perl-programming.p hp
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/