InSilicoSpectro::Spectra::PhenyxPeakDescriptor - InSilicoSpectro::Spectra::PhenyxPeakDescriptor documentation


InSilicoSpectro documentation Contained in the InSilicoSpectro distribution.

Index


Code Index:

NAME

Top

InSilicoSpectro::Spectra::PhenyxPeakDescriptor

SYNOPSIS

Top

  my $t=XML::Twig->new->parsefile($file);
  my @el=$t->get_xpath("ple:ItemOrder");
  my @pd;
  foreach(@el){
    my $pd=InSilicoSpectro::Spectra::PhenyxPeakDescriptor->new();
    $pd->readTwigEl($_);
    $pd->writeXml();
    push @pd, $pd;
  }
  print "comparing to first node\n";
  foreach(1..$#pd){
    print "$_ -> ".(($pd[$_]->equalsTo($pd[0]))?"OK":"!=")."\n";
  }

DESCRIPTION

Top

List of fields name related to peak Merely contains a list of names (ex ['mass', 'intensity', 'prob'])

FUNCTIONS

Top

METHODS

Top

my $pd=InSilicoSpectro::Spectra::PhenyxPeakDescriptor->new([\%h])
$pd->writeXml()
$pd->readTwigEl($tw)

Read info from an Xml::Twig node tagged <ple:ItemOrder>

EXAMPLES

Top

SEE ALSO

Top

COPYRIGHT

Top

AUTHORS

Top

Alexandre Masselot, www.genebio.com


InSilicoSpectro documentation Contained in the InSilicoSpectro distribution.

use strict;

package InSilicoSpectro::Spectra::PhenyxPeakDescriptor;
use Carp;

use  InSilicoSpectro::Spectra::PeakDescriptor;

our (@ISA,@EXPORT,@EXPORT_OK);
@ISA=qw (InSilicoSpectro::Spectra::PeakDescriptor);
@EXPORT=qw();
@EXPORT_OK=qw();


sub new{
  my $class=shift;
  my $self = InSilicoSpectro::Spectra::PeakDescriptor->new(@_);
  bless $self, $class;
  return $self;
}



use XML::Twig;
sub readTwigEl{
  my ($this, $t)=@_;
  confess unless $t;
  confess "InSilicoSpectro::Spectra::PhenyxPeakDescriptor::readTwigEl tag name should be (ple:)?ItemOrder" unless $t->gi =~/(ple:)?ItemOrder/;
  $this->{fieldNames}=[];
  foreach($t->children("ple:item"), $t->children("item")){
    my $f=$_->att('type') or croak "InSilicoSpectro::Spectra::PhenyxPeakDescriptor::readTwigEl no 'type' attribute for element ple:item";
    $this->pushField($f);
  }
}


sub writeXml{
  my ($this, $shift, $transformCharge)=@_;

  print "$shift<ple:ItemOrder xmlns:ple=\"namespace/PeakListExport.html\">\n";
  foreach (@{$this->{fieldNames}}){
    if ($transformCharge and ($_ eq 'chargemask')){
      print "$shift  <ple:item type=\"charge\"/>\n" ;
    }else{
      print "$shift  <ple:item type=\"$_\"/>\n";
    }
  }
  print "$shift</ple:ItemOrder>\n";
}


sub sprintData{
  my ($this, $data, $transformCharge)=@_;

  my $ret;
  my @tmp=reverse @$data;
  foreach (@{$this->{fieldNames}}){
    my $v=pop @tmp;
    if(not defined $v){
      $ret.="? ";
      next;
    }
    if($transformCharge and ($_ eq 'chargemask')){
      if($v eq '?' or not $v){
	$ret.='? ';
      }else{
	$ret.=InSilicoSpectro::Spectra::MSSpectra::chargemask2string($v)." ";
      }
    }else{
      $ret.="$v ";
    }
  }
  $ret=~s/\s+$//;
  return $ret;
}

return 1;