in reply to PERL HTML HELP

So in my experience as a programmer, syntax highlighting is a very helpful tool to indicate whether you've made an error in your coding. Things like missed closing quotes (which are quite tiny glyphs so not easy to spot) are made very visible by unexpected changes in colour.

Which brings me to my point. Colour-coded DNA! Syntax highlighting for the genome! If this helps stop DNA transcriptional errors, this could be the cure for cancer! :-)

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: PERL HTML HELP
by Singh121 (Initiate) on Oct 20, 2012 at 11:02 UTC
    makes sense :)
Re^2: PERL HTML HELP
by Singh121 (Initiate) on Oct 20, 2012 at 18:37 UTC
    I like the idea of having my protein sequences and the restriction enzymes displayed in various colours and i have been messing around with this but have had no luck, this is what i have tried:
    sub color { my($colorkey) = @_; my $color = ''; my %color_key = ( A => "<font color=#99CCCC> A </font>", C => "<font color=#00CC00> C </font>", G => "<font color=#FF99CC> G </font>", T => "<font color=#33CC66> T </font>", R => "<font color=#996666> R </font>", Y => "<font color=#006699> Y </font>", M => "<font color=#33CC00> M </font>", K => "<font color=#99CC00> K </font>", S => "<font color=#000066> S </font>", W => "<font color=#990000> W </font>", B => "<font color=#0000FF> F </font>", D => "<font color=#FF9900> F </font>", H => "<font color=#9900CC> H </font>", V => "<font color=#99CC66> V </font>", N => "<font color=#33CCFF> N </font>", L => "<font color=#006633> L </font>", P => "<font color=#990066> P </font>", Q => "<font color=#996600> Q </font>", I => "<font color=#9966CC> I </font>", E => "<font color=#FF9966> E </font>", _ => "<font color=#000000> _ </font>", ); # Translate each character in the sequence coloured character for ( my $i = 0 ; $i < length($colorkey) ; ++$i ) { $color .= $color_key{substr($colorkey, $i, 1)}; } return }
    it was a long shot but obviously did not work...trail and error eh lol either way i was wondering how would one get a key or something to store an individual amino acid as a different colour. I am assuming because the amino acid in my sequence is displayed in a string (here is my code for that):
    print "please enter the start point of your DNA sequence\n\n"; $dnastart = <STDIN>; chomp $dnastart; print "please enter the end point of your DNA sequence\n\n"; $dnaend = <STDIN>; chomp $dnaend; $dna = substr($dna, $dnastart, ($dnaend - $dnastart)); print"Here is your selected DNA sequence:\n\n $dna\n\n"; } #start the string from position 0 $protein = substr($dna,0); #Translate the DNA to protein $protein = dna2peptide($protein); #Print the sequence in lines of 50 characters long print"\n\n<----------------Peptide frame 1----------------> \n\n"; print_sequence ($protein,50); # printing data sequences to HTML print OUTFILE "<table border=1 width=50% bgcolor=#CCFFFF> <tr><td><b> Peptide sequence frame 1</td></tr></b> <tr></tr> <tr><td> $protein </td></tr> </table>";
    i would need some sort of code which does a substitution for each letter into color, which is what i was trying to accomplish with my horrible attempt above lol
      Your html still has some problems, but some are easily fixed by simply revising the quoting. Some may frown, and with reason, at this use of a 'heredoc' but it "just works" for a one-off:
      #!/usr/bin/perl use 5.012; my $protein = "chuck steak"; my $heredoc = <<END <table border="1" width="50%" bgcolor="#CCFFFF"> <tr><td><b> Peptide sequence frame 1</b></td></tr>\n <tr><td>$protein </td> <td>also 'walnuts'</td></tr> </table> END ; print $heredoc;

      OUTPUT:

      <table border="1" width="50%" bgcolor="#CCFFFF"> <tr><td><b> Peptide sequence frame 1</b></td></tr> <tr><td>chuck steak </td> <td>also 'walnuts'</td></tr> </table>

      Note the newline at the end of line 09; your empty tr></tr> will provoke complaints from some validators.

      Better, however, to devote a couple hours to familiarizing yourself with CSS1 and 2. And better yet to follow the broad guidance provided by blue_cowdawg ( above ) and to use such CSS constructs as "max-width: nn%" to assure that the wraps work (...err, semi-work.....) based on the user's current screen width.