in reply to Re^2: bold color text and export to file
in thread bold color text and export to file
Dear Roboticus and Anonymous Monk
Thank you for your suggestions and directions and I am extremely sorry for any confusion if any.
As you mentioned in your earlier post, that this will not work if the sequences are overlapping and I have found that some of my regions would be overlapping.
I was also thinking if this could be done by an array of range operator and for each array element the sequence will be either bold or colored.
Below is my code which I was trying:
#!/usr/bin/perl #use strict; use warnings; my $filename = "NM_014143.3.fasta"; my @name = split( /\./, $filename ); my $name = $name[0]; my ($infile, @temp); open( $infile, "<", $filename ) || die "Check the $filename $!\n"; while ( my $line = <$infile> ) { chomp $line; if ( $line =~ /^>/ ) { next; } elsif ( $line =~ /^\s*$/ ) { next; } elsif ( $line =~ /^\s*#/ ) { next; } else { $sequence .= $line; } } $sequence =~ s/\n//g; $sequence =~ s/\s+//g; #print "$sequence\n"; close ($infile); my @seq = (1 .. 15, 30 .. 40, 50 .. 60); #this is a range array for (my $pos=1;$pos<=length($sequence);$pos++){ foreach my $ar(@seq){ if($pos == $ar){ push (@temp, "<b>",$sequence, "</b"); } else{ push (@temp, $sequence); } } } my $tmp = join ("", @temp); print "$tmp\n";
Data file: GGCGCAACGCTGAGCAGCTGGCGCGTCCCGCGCGGCCCCAGTTCTGCGCAGCTTCCCGAGGCTCCGCACC + CC +TGCAGGGCATTCCAGAAAGATGAGGATATTTGCTGTCTTTATATTCATGACCATTTGCTGAACGCATT TACTGTCACGGTTCCCAAGGACCTATATGTGGTAGAGTATGGTAGC + AT +GACAATTGAATGCAAATTCCCAGTAGAAAAACAATTAGACCTGGCTGCACTAATTGTCTATTGGG AAATGGAGGATAAGAACATTATTCAATTTGTGCATGGAGAGGAAGACCTGAAGGTTCAGCATAGTAGCTA CAGACAGAGGGCCCGGCTGTTGAAGGACCAGCTCTCCCTGGGAAATGCTGCACTTCAGATCACAGATGTG AAATTGCAGGATGCAGGGGTGTACCGCTGCATGATCAGCTATGGTGGTGCCGACTACAAGCGAATTACTG TGAAAGTCAATGCCCCATACAACAAAATCAACCAAAGAATTTTGGTTGTGGATCCAGTCACCTCTGAACA TGAACTGACATGTCAGGCTGAGGGCTACCCCAAGGCCGAAGTCATCTGGACAAGCAGTGACCATCAAGTC CTGAGTGGTAAGACCACCACCACCAATTCCAAGAGAGAGGAGAAGCTTTTCAATGTGACCAGCACACTGA
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: bold color text and export to file
by roboticus (Chancellor) on Sep 23, 2014 at 19:47 UTC | |
by newtoperlprog (Sexton) on Sep 23, 2014 at 20:58 UTC |