G
Prelude
Globals (from use vars definitions) |
$AUTOLOAD |
@INC |
$VERSION = '1.0' |
use G::Prelude; @ISA = (G::Prelude);
|
Intended for internal use only. Super class for the core. Provides the native methods.
|
after_startcodon | No description | Code |
after_stopcodon | No description | Code |
before_startcodon | No description | Code |
before_stopcodon | No description | Code |
cds | No description | Code |
del_key | No description | Code |
feature | No description | Code |
gene2id | No description | Code |
get_cdsseq | No description | Code |
get_exon | No description | Code |
get_gbkseq | No description | Code |
get_geneseq | No description | Code |
get_intron | No description | Code |
getseq | No description | Code |
hairpin_cut | No description | Code |
intergenic | No description | Code |
pos2feature | No description | Code |
pos2gene | No description | Code |
seq_info | No description | Code |
set_intergenic | No description | Code |
startcodon | No description | Code |
stopcodon | No description | Code |
Methods description
Methods code
after_startcodon | description | top | prev | next |
sub after_startcodon
{ my $this = shift;
my $object = shift;
my $length = shift;
if ($this->{$object}->{direction} eq 'complement'){
return
complement(substr($this->{SEQ},
$this->{$object}->{end} - 1 - 3 - $length + 1,
$length));
}else{
return
substr($this->{SEQ},
$this->{$object}->{start} + 3 - 1,
$length);
}
}
sub after_stopcodon
{ my $this = shift;
my $object = shift;
my $length = shift;
if ($this->{$object}->{direction} eq 'complement'){
return
complement(substr($this->{SEQ},
$this->{$object}->{start} - 1 - $length,
$length));
}else{
return
substr($this->{SEQ},
$this->{$object}->{end} +1 - 1,
$length);
}
}
sub before_startcodon
{ my $this = shift;
my $object = shift;
my $length = shift;
if ($this->{$object}->{direction} eq 'complement'){
return
complement(substr($this->{SEQ},
$this->{$object}->{end},
$length));
}else{
return
substr($this->{SEQ},
$this->{$object}->{start} - 1 - $length,
$length);
}
}
sub before_stopcodon
{ my $this = shift;
my $object = shift;
my $length = shift;
if ($this->{$object}->{direction} eq 'complement'){
return
complement(substr($this->{SEQ},
$this->{$object}->{start} + 3 - 1,
$length));
}else{
return
substr($this->{SEQ},
$this->{$object}->{end} - 3 - 1 - $length + 1,
$length);
}
}
sub cds
{ my $this = shift;
my $opt = shift || '';
my $i = 0;
my @cds;
while(defined(%{$this->{"FEATURE" . ($i + 1)}})){
$i ++;
next if ($this->{"FEATURE$i"}->{type} ne 'CDS');
if ($opt ne 'all'){
next if ($this->{"FEATURE$i"}->{on} == 0);
my $id = $this->{"FEATURE$i"}->{cds};
next if ($this->{"CDS$id"}->{on} == 0);
}
push (@cds, "FEATURE$i");
}
return @cds;
}
sub del_key
{ my $this = shift;
my $key = shift;
$this->{$key}->{on} = 0;
return 1;
}
sub feature
{ my $this = shift;
my $opt = shift || '';
my $i = 0;
my @feature;
while(defined(%{$this->{"FEATURE" . ($i + 1)}})){
if ($opt ne 'all' && defined $this->{"FEATURE$i"}->{on}){
next if ($this->{"FEATURE$i"}->{on} == 0);
}
push (@feature, "FEATURE$i");
$i ++;
}
return @feature;
}
sub gene2id
{ my $this = shift;
my $gene = shift;
foreach my $feat ($this->cds()){
return $feat if ($this->{$feat}->{gene} eq $gene);
}
}
sub get_cdsseq
{ my $this = shift;
my $object = shift;
my $cdsseq = $this->get_gbkseq($this->{$object}->{start},
$this->{$object}->{end});
$cdsseq = &complement($cdsseq)
if ($this->{$object}->{direction} eq 'complement');
return $cdsseq;
}
sub get_exon
{ my $this = shift;
my $cds = shift;
unless ($this->{$cds}->{join}){
return -1;
last;
}
my @join = split(/,/, $this->{$cds}->{join});
my $seq = '';
my $line;
foreach $line (@join){
my $complement = $line =~ tr/c//d;
my ($start, $end) = split(/\.\./, $line, 2);
my $tmp = $this->get_gbkseq($start, $end);
$tmp = complement($tmp) if ($complement);
$seq .= $tmp;
}
$seq = complement($seq) if ($this->{$cds}->{direction} eq 'complement');
return $seq;
}
sub get_gbkseq
{ my $this = shift;
my $start = shift;
my $end = shift;
my $seq = substr($this->{SEQ}, $start -1, $end-$start+1);
return $seq;
}
sub get_geneseq
{ my $this = shift;
my $object = shift;
my $geneseq = $this->get_gbkseq($this->{$object}->{start},
$this->{$object}->{end});
if ($this->{$object}->{join}){
$geneseq = $this->get_exon($object);
}elsif ($this->{$object}->{direction} eq 'complement'){
$geneseq = &complement($geneseq);
}
return $geneseq;
}
sub get_intron
{ my $this = shift;
my $cds = shift;
unless ($this->{$cds}->{join}){
return -1;
last;
}
my @join = split(/\.\./, $this->{$cds}->{join});
shift @join;
pop @join;
my @seq;
my $line;
foreach $line (@join){
$line =~ s/c//g;
my ($start, $end) = split(/,/, $line, 2);
my $tmp = $this->get_gbkseq($start + 1, $end - 1);
push (@seq, $tmp);
}
return @seq;
}
sub getseq
{ my $this = shift;
my $start = shift;
my $end = shift;
my $seq = substr($this->{SEQ}, $start, $end-$start+1);
return $seq;
}
sub hairpin_cut
{ my $nuc = shift;
my $val = "\n==============\n!!!Afro Man!!!===============\n\n";
system('netscape http://www2.osk.3web.ne.jp/~e916/');
return $val;
}
sub intergenic
{ my $this = shift;
my $opt = shift || '';
my $i = 0;
my @cds;
while(defined(%{$this->{"INTER" . ($i + 1)}})){
$i ++;
if ($opt ne 'all'){
next if ($this->{"INTER$i"}->{on} == 0);
}
push (@cds, "INTER$i");
}
return @cds;
}
sub pos2feature
{ my $this = shift;
my $pos = shift;
foreach my $feat ($this->feature()){
next if ($feat eq 'FEATURE0');
if ($pos >= $this->{$feat}->{start} && $pos <= $this->{$feat}->{end}){
return $feat;
}elsif ($pos < $this->{$feat}->{start}){
return '';
}
}
}
sub pos2gene
{ my $this = shift;
my $pos = shift;
foreach my $feat ($this->cds()){
if ($pos >= $this->{$feat}->{start} && $pos <= $this->{$feat}->{end}){
return $feat;
}elsif ($pos < $this->{$feat}->{start}){
return '';
}
}
}
sub seq_info
{ my $this = shift;
my $length = length($this->{SEQ});
my $a = $this->{SEQ} =~ tr/a/a/;
my $t = $this->{SEQ} =~ tr/t/t/;
my $g = $this->{SEQ} =~ tr/g/g/;
my $c = $this->{SEQ} =~ tr/c/c/;
my $others = $length - $a - $t - $g - $c;
my $msg;
$msg .= sprintf "\n\nAccession Number: %s\n", $this->{LOCUS}->{id};
$msg .= sprintf "\n Length of Sequence : %9d\n" , $length;
$msg .= sprintf " A Content : %9d (%.2f",
$a , $a / $length * 100;
$msg .= "\%)\n";
$msg .= sprintf " T Content : %9d (%.2f",
$t , $t / $length * 100;
$msg .= "\%)\n";
$msg .= sprintf " G Content : %9d (%.2f",
$g , $g / $length * 100;
$msg .= "\%)\n";
$msg .= sprintf " C Content : %9d (%.2f",
$c , $c / $length * 100;
$msg .= "\%)\n";
$msg .= sprintf " Others : %9d (%.2f",
$others, $others / $length * 100;
$msg .= "\%)\n";
$msg .= sprintf " AT Content : %.2f",
($a + $t) / $length * 100;
$msg .= "\%\n";
$msg .= sprintf " GC Content : %.2f",
($g + $c) / $length * 100;
$msg .= "\%\n\n";
&msg_send($msg);
return ($a, $t, $g, $c);
}
sub set_intergenic
{ my $gb = shift;
my $num = 1;
my $i = 0;
my $length = length $gb->{SEQ};
my $cds = scalar($gb->cds());
my $so = $gb->{"CDS$cds"}->{end} + 1;
while(defined(%{$gb->{"CDS$i"}})){
if($i == 0){
my $sta = $gb->{CDS1}->{start} - 1;
$gb->{"INTER$num"}->{start} = 1;
$gb->{"INTER$num"}->{end} = $sta;
$gb->{"INTER$num"}->{direction} = "direct";
$gb->{"INTER$num"}->{on} = 1;
$num++;
}elsif($i == $cds){
$gb->{"INTER$num"}->{start} = $so;
$gb->{"INTER$num"}->{end} = $length;
$gb->{"INTER$num"}->{direction} = "direct";
$gb->{"INTER$num"}->{on} = 1;
$num++;
}elsif($i > 0){
my $it = $i + 1;
my $start = $gb->{"CDS$i"}->{end};
my $end = $gb->{"CDS$it"}->{start};
if($start < $end){
$start ++;
$end --;
$gb->{"INTER$num"}->{start} = $start;
$gb->{"INTER$num"}->{end} = $end;
$gb->{"INTER$num"}->{direction} = "direct";
$gb->{"INTER$num"}->{on} = 1;
$num++;
}
}
$i++;
}
}
sub startcodon
{ my $this = shift;
my $object = shift;
return substr($this->get_geneseq($object), 0, 3);
}
sub stopcodon
{ my $this = shift;
my $object = shift;
return substr($this->get_geneseq($object), -3, 3);
}
General documentation