BioMart::Formatter
MFA
Toolbar
Summary
BioMart::Formatter::MFA
Package variables
No package variables defined.
Inherit
Synopsis
TODO: Synopsis here.
Description
Methods
_get_aligned_sequence_from_original_sequence_and_cigar_line | No description | Code |
_new | No description | Code |
_rc | No description | Code |
_rcCigarLine | No description | Code |
getDisplayNames | No description | Code |
isSpecial | No description | Code |
nextRow | No description | Code |
preProcessRow | No description | Code |
preProcessRowMlagan | No description | Code |
processQuery | No description | Code |
returnMFAline | No description | Code |
Methods description
None available.
Methods code
_get_aligned_sequence_from_original_sequence_and_cigar_line | description | prev | next | Top |
sub _get_aligned_sequence_from_original_sequence_and_cigar_line
{
my ($original_sequence, $cigar_line) = @_;
my $aligned_sequence = "";
return undef if (!$original_sequence or !$cigar_line);
my $seq_pos = 0;
my @cig = ( $cigar_line =~ /(\d*[GMD])/g );
for my $cigElem ( @cig ) {
my $cigType = substr( $cigElem, -1, 1 );
my $cigCount = substr( $cigElem, 0 ,-1 );
$cigCount = 1 unless ($cigCount =~ /^\d+$/);
if( $cigType eq "M" ) {
$aligned_sequence .= substr($original_sequence, $seq_pos, $cigCount);
$seq_pos += $cigCount;
} elsif( $cigType eq "G" or $cigType eq "D") {
$aligned_sequence .= "-" x $cigCount;
}
}
warn ("Cigar line ($seq_pos) does not match sequence lenght (".length($original_sequence).")") if ($seq_pos != length($original_sequence));
return $aligned_sequence;
}
} |
sub _new
{ my ($self) = @_;
$self->SUPER::_new(); } |
sub _rc
{ my ($seq) = @_;
$seq = reverse($seq);
$seq =~ tr/YABCDGHKMRSTUVyabcdghkmrstuv/RTVGHCDMKYSAABrtvghcdmkysaab/;
return $seq;
}
} |
sub _rcCigarLine
{ my ($cigar_line) = @_;
my @cig = ( $cigar_line =~ /(\d*[GMD])/g );
my @rev_cigar = reverse(@cig);
my $rev_cigar;
for my $cigElem ( @rev_cigar ) {
$rev_cigar.=$cigElem;
}
return $rev_cigar;
}
} |
sub getDisplayNames
{ my $self = shift;
return '' ;
}
} |
sub isSpecial
{ return 1;
}
1; } |
sub nextRow
{ my $self = shift;
my @data ;
my $PROCESSED_SEQS ;
my $rtable = $self->get('result_table');
my $row = $rtable->nextRow;
if (!$row){
return;
}
if ( ( ($$row[0]=~/^(A|C|G|T|N)/) && ($$row[0]!~/^(Chr)/) ) && ( ($$row[1]=~/^(A|C|G|T|N)/) && ($$row[1]!~/^(Chr)/) ) ){ @data = &preProcessRowMlagan(\@{$row});
foreach my $foo (@data){
my $seq = $foo->[0] ;
my $chr = $foo->[1] ;
my $start = $foo->[2] ;
my $end = $foo->[3] ;
my $strand = $foo->[4] ;
my $length = $foo->[5] ;
my $genome = $foo->[6] ;
my $cigar = $foo->[7] ;
my $score = $foo->[8] ;
my @prearray = ($seq,$chr,$start,$end,$strand,$length,$genome,$cigar,$score);
$PROCESSED_SEQS .= &returnMFAline(@prearray);
}
}
return $PROCESSED_SEQS . "#\n";
}
} |
sub preProcessRow
{ my $row = shift ;
my @want ;
my $to = 0;
my $score;
my $size_row = @{$row};
while ($size_row > 0) {
if ($to == 0) {
for (my $i=0;$i<=6;$i++){
$want[$to][$i] = shift (@{$row});
}
$score = shift (@{$row});
$to++;
}
else {
for (my $i=0;$i<=6;$i++){
$want[$to][$i] = shift (@{$row});
}
$to++;
}
$size_row = @{$row};
}
my $size = @want;
return (@want, $score);
}
} |
sub preProcessRowMlagan
{ my $row = shift ;
my @want ;
my $score;
my $k = 0;
my $size_row = @{$row};
while ( ($$row[0]=~/^(A|C|G|T|N)/) && ($$row[0]!~/^Chr/i) && ($$row[0]!~/\_/) ){ $want[$k][0] = shift (@{$row});
$k++;
}
for (my $j=0;$j<=$k-1;$j++){
for (my $i=1;$i<=8;$i++){ $want[$j][$i] = shift (@{$row});
}
}
return (@want);
}
} |
sub processQuery
{ my ($self, $query) = @_;
$self->set('original_attributes',[@{$query->getAllAttributes()}]) if ($query->getAllAttributes());
$self->set('query',$query);
return $query; } |
returnMFAline | description | prev | next | Top |
sub returnMFAline
{ my ($seq,$chr,$start,$end,$strand,$length,$genome,$cigar,$score) = @_;
my ($length_seq,$hstrand,$hstart,$hend);
my $fasta_seq;
if ($strand > 0){
$length_seq = length ($seq);
$hstrand = "+";
$hstart = $start;
$hend = $end;
} elsif ($strand < 0){
$length_seq = length ($seq);
$hstrand = "-";
$hstart = $length - $end + 1;
$hend = $length - $start + 1;
} else { warn "\n\n\nProblem in returning mfa formated lines\n\n\n ";}
my $header = ">" . join("|",("chr:".$chr),"start:".$start,"end:".$end,"strand:".$strand,"score:".$score,$genome);
my $formated_seq = _get_aligned_sequence_from_original_sequence_and_cigar_line($seq, $cigar);
while ($formated_seq =~ /(.{1,80})/g) {
$fasta_seq .= $1 ."\n";
}
return ($header."\n".$fasta_seq);
}
} |
General documentation
>chr:21|start:20941549|end:20941788|strand:1
TTTGCAGATATTGCAGCTTTTTACAAATTGAAGGTTTGTGGCAACCCTGC----------------ATGCAACCAGTCTG
TTGGCATC---ATTTTGTGT--------------TATATT--TTGGTAATTCTCTCAATATTTCAGACTGTTTCATTATC
ATTATATCTGTTATGGTGTTGTATAATCAGTGACCTTTGATG---TTACTATTGTAATTGTTTTAGAGTGCCAAGGTCTG
TGCCCCAAAAAAGGTGGCTAACATATTCAGTAAATAAA
>chr:1|start:4265565|end:4265824|strand:-1
TTTACTGATGT-GTAGTTTTATTTTAATTGAAAGTGGG-GACAACCGTGTTGCACTGGTCTTATAAGTGCCATCATTCCA
TTAATGTCTTTACTTTGTGTGTGCCCCCATGTCTCATTTTGCTTGGTATTTTTAATAATATTCCAAATGTTTTCATGTTT
ATT--------CATTATGTTATATCATCTGTGATCTTTGATGTTATTATTATTATAACTATTTTAAGGCACCACAAACTA
TGTAC--------ATAATTAACAAGCTTAATAAACAAA
#