MeltDBWiki/ListAlignments

From BRF-Software
Revision as of 12:52, 4 April 2008 by imported>HeikoNeuweger
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

List Chromatogram Alignment information

  • List all computed alignment anchors for a reference 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 "export_alignments - list aligned positions for a reference chromatogram.".
	"-p project name -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 set latest annotation: No project 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;
}

my $master = $app_frame->application_master();
my $chromatogram = $master->AC->Chromatogram->init_name($opt_c);

foreach my $obs  (@{$master->Observation->Chromatogram->Alignment()->fetchallby_reference_chromatogram($chromatogram)}) {
    print $chromatogram->rawChromatogram()."\t".$obs->chromatogram->rawChromatogram()."\n";
    foreach my $pair (@{$obs->index_pairs()}) {
	print $pair->[0]."\t".$pair->[1]."\n";
    }
}
 



glucoseA.cdf      glucoseB.cdf
21      24
94      94
146     148
195     196
228     229
302     302
388     389
452     452
501     500
527     528
585     585
630     630
695     696
722     723
815     814
1060    1061
1077    1077
1091    1092
1143    1145
1191    1192
1270    1271
...