Bio-Maxd

 view release on metacpan or  search on metacpan

lib/Bio/Maxd.pm  view on Meta::CPAN


sub _experimentIDfromExperiment {
  my($dbh,$name,$subid) = @_;
  my($id);
  my $st = "select Name,ID from Experiment where submitter_id = $subid and ";
  if ($name =~ /^\d+$/) {$st .= qq{ID = "$name"};} else {$st .= qq{ Name = "$name"};}
  my $sh = $dbh->prepare($st);
  my $rv = $sh->execute;
  ($name,$id)= $sh->fetchrow_array;
  $id = "-1" unless defined $id;
  $name = "" unless defined $name;
  return ($id,$name);
}

sub _arrayIDfromArrayType {
  my($dbh,$arrayType)=@_;
  my $st = qq{select ID from ArrayType where Name = "$arrayType"};
  my $sh = $dbh->prepare($st);
  my $rv = $sh->execute;
  my $id = $sh->fetchrow_array;
  $id = "-1" unless defined $id;
  return $id;
}

sub _theFileFormat {
  my($f) = @_; my($l,$fileType);
  open(IN,$f); $l = <IN>; close(IN);
  if ($l =~ /Expression Analysis: Metrics Tab/) {
    $fileType = "AFF";
  } elsif ($l =~ /^\?\?/) {
    $fileType = "TOR";
  } else {
    $fileType = "UNK";
  }
  return $fileType;
}

sub _error {
  my($errnum,$errval)=@_;
  print STDERR "Error $errnum: $errval\n";
  return 0;
}

1;
__END__
=head1 NAME

Bio::Maxd - Perl extension for storing and retrieving data from maxd

=head1 SYNOPSIS

  use Bio::Maxd;
  my $maxd_db = new Bio::Maxd (-user=>'user', -pass=>'pass', 
                               -host=>'host', -dbase=>'database');
  $maxd_db->load_file(-file=>'path_to_data_file',
                  -experiment=>'experimentName', -array_type=>'geneChipName');
  $maxd_db->disconnect();

=head1 DESCRIPTION

B<Bio::Maxd> provides methods for uploading and retrieving
data to/from a maxd (MySQL) database.

"maxd" is a data warehouse and visualization environment for microarray
expression data developed by the Microarray Group at
Manchester Bioinformatics (http://www.bioinf.man.ac.uk/microarray/)

=head2 Bio::Maxd METHODS

B<new()>, This is the constructor for B<Bio::Maxd>.

 my $maxd_db = new Bio::Maxd();

This is the constructor for B<Bio::Maxd>. 
It establishes a database connection, or session, to the requested database.
Parameters:

=over 4

=item B<-user> and B<-pass>, default to $ENV{'MAXD_USERID'} with user/password.

=item B<-host>, defaults to $ENV{'MAXD_DBHOST'}, hostname or "localhost".

=item B<-dbase>, defaults to 'maxd'.

=item B<-verbose>, defaults to false.

=back

B<load_file()>, Parses and loads a datafile into a maxd database.. 

=over 4

=item B<-file>, datafile to parse.

=item B<-format>, data file format; Bio::Maxd will guess it, if not provided. 
Valid values are 'AFF' (Affimetrix matrics file)

=item B<-experiment>, Experiment ID or Experiment name.

=item B<-array_type>, ArrayType ID or ArrayType name

=back

B<export()>, Exports data from maxd database..

=over 4

=item B<-verbose>, reports activity.

=item B<-format>, desired format for the data to be exporte to. Valid values are 'GeneSpring'.

=item B<-submitter>, submitter name or id.

=item B<-experiment>, experiment name or id.

=item B<-array_type>, array name, i.e. 'HG-U95A2'

=item B<-repository_URL>, where to install files.

=item B<-image>, image name or id.



( run in 1.958 second using v1.01-cache-2.11-cpan-b16cb0d3907 )