Subject: Re: Can we color peaks differently when using the "rp" accelerator ?[Thanks]
From: liwenfu24
Date: Jun 9, 2007

Previous: 391 Next: 396


Dear Tom Goddard and Mandar Naik,

Thank you very much for your timely reply!

Now, I can color the peak labels (not peaks) differently according to
the peak notes when using the rp command to read peaks.

First, I add peak notes at the end of each line in .list file, say
candid.


A27CA-I30HD1-A27HA 55.696 0.750 3.999 candid
A27CB-I24HA-A27HB 17.757 3.416 1.391 candid


Then I read the peak list to Sparky with rp accelerator.
At this moment, I usually color those peaks (not peak labels) in a
specific color, so that I can operate those peaks when necessary.

So far, I have not found a command in Sparky that can select all those
peak labels (not peaks), therefore I change the color of those peak
labels (not peaks) by modifying the .save file with a perl script.

Now those peak labels can be colored in anything I want them to be.


Regards,

Liwen

By the way, I think there might be a bug with Sparky:
the peak notes will be followed by a n(new line) mark.
when reading peak list (rp).

This can be visulized by using the lt accelerator (make sure that
the note option has been checked.)

The version of Sparky I used is 3.110.

===========================================================
The following is the perl script for modifying .save file.

#!/usr/bin/perl
#


# Tested platform(s): It works on Red Hat Linux 9 (perl, v5.8.0)
#


if ($#ARGV != 1) { print n Usage: $0 input_file(original.save)
output_file(modified.save)n;
print Notes: n;
print input_file(original.save) .save file of Sparky.
n;
print peak notes must be
appended before running this script. n;
print output_file(modified.save) .save
file of Sparky; n;
print peak labels will be
colored according to the peak notes. nn;
print supported peak notes:
n;
print cand(CANDID): cyan; sane(SANE): yellow;
manu(Manually): white; aria(ARIA): pink. nn;
print If a peak doesnt have a peak note, it will also
be colored in white. nn; exit;}




$input_file_original = $ARGV[0];

$output_file_modified = $ARGV[1];


open(filehandle_inp_original,$input_file_original) ||
die (ncannot open the input file: $input_file_original nn);

open(filehandle_out_modified,$output_file_modified) or
die (ncannot open the output file: $output_file_modified nn);

$num_peaks = 0;
$num_lines = 0;
$flag_peaks = 0;


while ($readline_original = filehandle_inp_original)
{
# If no such line, the last element of the array will be followd by n.
chomp $readline_original;

@array_original_temp = split(/ +/, $readline_original);

if ($readline_original eq type peak) {
$num_peaks++;
$array_readline_original[$num_peaks][0] = $readline_original; # type peak

for ($m = 0; $m = $num_lines; $m++) { # $num_lines of the
previous peak

@array_original_note = split(/ +/,
$array_readline_original[$num_peaks-1][$m]);

if (@array_original_note[0] eq note) {

@array_original_note_qu = split(, @array_original_note[1]);

if (@array_original_note_qu[1] eq cand){
$flag_cand = 1;
}elsif (@array_original_note_qu[1] eq sane){
$flag_sane = 1;
}elsif (@array_original_note_qu[1] eq manu){
$flag_manu = 1;
}elsif (@array_original_note_qu[1] eq cyan){
$flag_aria = 1;
} # if @array_original_note_qu[1]


} # if

} # for

#printf %sn, $readline_original;
#printf %sn, $num_lines;
for ($n = 0; $n = $num_lines; $n++) {

@array_original = split(/ +/,
$array_readline_original[$num_peaks-1][$n]);

if ($array_readline_original[$num_peaks-1][$n-1] eq type
label && @array_original[0] eq color) {

if ($flag_cand == 1) {
printf %s %s %s %s %sn, @array_original[0],
@array_original[1], @array_original[2], @array_original[3], cyan;
printf filehandle_out_modified %s %s %s %s %sn,
@array_original[0], @array_original[1], @array_original[2],
@array_original[3], cyan; # n cannot be used.
$flag_cand = 0;
} elsif ($flag_sane == 1) {
printf %s %s %s %s %sn, @array_original[0],
@array_original[1], @array_original[2], @array_original[3], yellow;
printf filehandle_out_modified %s %s %s %s %sn,
@array_original[0], @array_original[1], @array_original[2],
@array_original[3], yellow; # n cannot be used.
$flag_sane = 0;
} elsif ($flag_manu == 1) {
printf %s %s %s %s %sn, @array_original[0],
@array_original[1], @array_original[2], @array_original[3], white;
printf filehandle_out_modified %s %s %s %s %sn,
@array_original[0], @array_original[1], @array_original[2],
@array_original[3], white; # n cannot be used.
$flag_manu = 0;
} elsif ($flag_aria == 1) {
printf %s %s %s %s %sn, @array_original[0],
@array_original[1], @array_original[2], @array_original[3], pink;
printf filehandle_out_modified %s %s %s %s %sn,
@array_original[0], @array_original[1], @array_original[2],
@array_original[3], pink; # n cannot be used.
$flag_aria = 0;
} # if $flag_XXX

} else {
if (($num_peaks-1) == 0 && $n == 0) {
# $array_readline_original[0][0] = ;
}else {

@array_original_note_print = split(/ +/,
$array_readline_original[$num_peaks-1][$n]);

if (@array_original_note_print[0] eq note) {
printf %s, $array_readline_original[$num_peaks-1][$n];
printf filehandle_out_modified %s,
$array_readline_original[$num_peaks-1][$n];
} else {
printf %sn,
$array_readline_original[$num_peaks-1][$n];
printf filehandle_out_modified %sn,
$array_readline_original[$num_peaks-1][$n];
} #

} # if first line
} # if

} # for $n

$num_lines = 0;

} else {

$num_lines++;

$array_readline_original[$num_peaks][$num_lines] = $readline_original;
# type peak
#printf %sn, $readline_original;

} # if


} # while



# print the ornaments of the last peak, end ornament and end spectrum.
for ($n = 0; $n = $num_lines; $n++) {

@array_original_note_print = split(/ +/,
$array_readline_original[$num_peaks][$n]);

if (@array_original_note_print[0] eq note) {
printf %s, $array_readline_original[$num_peaks][$n];
printf filehandle_out_modified %s,
$array_readline_original[$num_peaks][$n];
} else {
printf %sn, $array_readline_original[$num_peaks][$n];
printf filehandle_out_modified %sn,
$array_readline_original[$num_peaks][$n];
} #

} # for $n end



###################################################################

print n The conversion has been finished successfully!n;
print n Please check the outputs! n,n;


close (filehandle_out_modified);

close (filehandle_inp_original);