Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Dot-plot help please

by utterlyconfused (Novice)
on Feb 13, 2011 at 16:57 UTC ( #887878=perlquestion: print w/replies, xml ) Need Help??
utterlyconfused has asked for the wisdom of the Perl Monks concerning the following question:

Hi Perlmonks

This is for a bioinformatics assignment that I have to complete. I'm aware there are forums for this and I have posted there but still have no reply.

I need help with getting the output to look the way I want it. I am comparing two strings (sequences) with one across the top and the other down the side with dots printed everywhere there's a match.
The problem is that the sequences are too long to fit on one line. Is there a way, whether it be in the code itself or in the UNIX terminal, to get it to display within the terminal space. The letters don't necessarily need to be legible. It's the pattern of dots that is important. I would appreciate it if you could take a look at my code and let me know what changes I could make to achieve this.

#!/usr/bin/perl use strict;use warnings; my $i;my $j;my $a; open (FH1,'<', "./CAM3UCA.txt"); open (FH2,'<', "./TCH3A.txt"); my $seq1 = do { local $/; <FH1> }; my $seq2 = do { local $/; <FH2> }; my @s1=split('',$seq1); my @s2=split('',$seq2); my @matrix=(); for($i=0;$i<scalar(@s2);$i++) { for($j=0;$j<scalar(@s1);$j++) { if($s2[$i] eq $s1[$j]) { $matrix[$i][$j]="."; } else { $matrix[$i][$j]=" "; } } } #Printing matrix of dot plot open (FHOUT,">dotplot.txt") or die "cannot open outfile\n"; for($a=0;$a<scalar(@s1);$a++) { print FHOUT "$s1[$a]"; } print FHOUT "\n"; #print"\n\n"; for($i=0;$i<scalar(@s2);$i++) { print FHOUT "$s2[$i]"; for($j=0;$j<scalar(@s1);$j++) { print FHOUT "$matrix[$i][$j]"; } print FHOUT "\n"; #print"\n\n"; } close FH1; close FH2; close FHOUT;

Replies are listed 'Best First'.
Re: Dot-plot help please
by biohisham (Priest) on Feb 13, 2011 at 18:15 UTC
    Your option is to change the font size to a very small size so that the alignment diagonals look visible from the dots arrangement, that's what happens in dot plotter programs like EMBOSS, depending on the length of the sequences the viewing of the alignment can be adjusted by increasing/decreasing the font size and you have to deactivate word-wrapping as well just in case..

    Another option, if you can use any of the modules in the Bio::Align space...

    Excellence is an Endeavor of Persistence. A Year-Old Monk :D .
Re: Dot-plot help please
by roboticus (Chancellor) on Feb 13, 2011 at 19:08 UTC


    There's a tool I've never used called asciitopgm that can convert an ascii image to a graphic image. That may do the trick for you.


    When your only tool is a hammer, all problems look like your thumb.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://887878]
Approved by biohisham
Front-paged by planetscape
Discipulus ignores..
Discipulus IE just maps to id est in my mind .. ;=)
[Corion]: marto: I believe nowadays, at least window.opener should not be set anymore (except maybe within the same domain)
[Corion]: But I wouldn't really know as I don't use iexplore much (except at $work) and mostly surf with JS disabled (except at $work :) )
[marto]: yeah, this is at work, where some intranet app launches links via When users close the intranet page so that only the new JS opened windows exist, clicking URLs in an email (or whatever) don't open

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2018-03-21 11:45 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (267 votes). Check out past polls.