MeltDBWiki/ListAnnotations: Difference between revisions

From BRF-Software
Jump to navigation Jump to search
imported>HeikoNeuweger
No edit summary
m (4 revisions)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
[[ListAnnotations]]
=== List Peak Annotations ===


* This sample script will connect to your MeltDB Server and print all annotations associated to Peaks in your chromatogram.
* This sample script will connect to your MeltDB Server and print all annotations associated to Peaks in your chromatogram.


 
<pre><nowiki>
<pre><nowiki>
#!/usr/bin/env perl
#!/usr/bin/env perl
Line 99: Line 99:
}
}


  </nowiki></pre>
</nowiki></pre>




The output of the script consists of two tab separated columns, the first gives the ''Retention Time'' of the peak in seconds and the second columns contains the ''Description'' of the latest annotation.
* The output of the script consists of two tab separated columns, the first gives the ''Retention Time'' of the peak in seconds and the second columns contains the ''Description'' of the latest annotation.
 


<pre><nowiki>
<pre><nowiki>
Retention Time  Annotation
Retention Time  Annotation
Line 113: Line 113:
823.45302      Xcalibur annotation: Leucin(158)
823.45302      Xcalibur annotation: Leucin(158)
....
....
</nowiki></pre>
</nowiki></pre>

Latest revision as of 07:13, 26 October 2011

List Peak Annotations

  • This sample script will connect to your MeltDB Server and print all annotations associated to Peaks in your chromatogram.


#!/usr/bin/env perl

use strict;
use warnings;

use GPMS::Application_Frame::MELTDB;
use strict;
use Carp;
use Getopt::Std;
use Term::ReadKey;
use IO::Handle;


#  this is necessary if the script is started via rsh(1)
#  otherwise you won't see any output until the first <RETURN>
#
STDOUT->autoflush(1);

sub usage {
    print "list latest peak annotation of a chromatogram in MeltDB.".
	"-p project name\n".
	"-c chromatogram name\n";
}

# global variables
our($opt_p, $opt_c);
			   
getopts('p:c:');

# start sanity checks
if (!$opt_p) {
    usage;
    print "ERROR: Can't start script list_peak_annotations: No project name given!\n";
    exit 1;
};

# start sanity checks
if (!$opt_c) {
    usage;
    print "ERROR: Can't start script list_peak_annotations: No chromatogram name given!\n";
    exit 1;
};

my $usr = defined( $ENV{'LOGNAME'} ) ? $ENV{'LOGNAME'} : (getpwuid( $> ))[0];

print STDOUT "Enter your database password: ";
ReadMode('noecho');
my $password = ReadLine(0);
chomp $password;
print STDOUT "\n";
ReadMode('normal');

# initialize project
my $app_frame = GPMS::Application_Frame::MELTDB->new($usr,
						    $password);

unless(ref $app_frame){
    print "Error, could not connect to database, wrong password?\n";
    exit 1;
}

my $project_name = $opt_p;

unless($app_frame->project($project_name)){
    print "Error, could not init project $project_name\n";
    exit 1;
}

# initialize MeltDB master 
my $master = $app_frame->application_master();

# initialize MeltDB Chromatogram object
my $chromatogram = $master->AC->Chromatogram->init_name($opt_c);

unless(ref $chromatogram && $chromatogram->isa("MELT::DB::AC::Chromatogram")) {
    print "Error, could not initialize $opt_c!\n";
    exit 1;
}

# generating the output

print "Retention Time\tAnnotation\n";


# fetch all peaks and sort them by retention time
foreach my $peak (sort {$a->rt <=> $b->rt()} @{$master->Peak->fetchallby_chromatogram($chromatogram)}) {
    my $latest_anno = $peak->latest_annotation();
    # only peaks with annotations will be listed
    if (ref $latest_anno && $latest_anno->isa("MELT::DB::Annotation")) {
	print $peak->rt(), "\t", $latest_anno->description(), "\n";
    }
}

 


  • The output of the script consists of two tab separated columns, the first gives the Retention Time of the peak in seconds and the second columns contains the Description of the latest annotation.


Retention Time  Annotation
483.17202       Xcalibur annotation: Pyruvat(174)
556.99998       Xcalibur annotation: Alanin(116)
730.24998       Xcalibur annotation: Valin(144)
799.578         Xcalibur annotation: Urea(189)
823.45302       Xcalibur annotation: Leucin(158)
....