Bio-BioStudio

 view release on metacpan or  search on metacpan

lib/Bio/BioStudio/Chromosome.pm  view on Meta::CPAN

    my @arr = @{$value};
    foreach my $line (@arr)
    {
      $line .= "\n" if (substr $line, -1, 1 ne "\n");
      unshift @{$self->{comments}}, $line;
    }
  }
  return @{$self->{comments}};
}

=head2 add_reason

=cut

sub add_reason
{
  my ($self, $editor, $memo) = @_;
  $self->comments();
  my $header = q{# # # } . $self->today();
  $header .= q{ by } . $editor . q{ (} . $memo . q{)};
  $self->add_to_comments([$header]);
  return;
}

=head2 GD

=cut

sub GD
{
  my ($self) = @_;
  return $self->{GD};
}

=head1 FUNCTIONS

=cut

=head2 rollback

=cut

sub rollback
{
  my ($self) = @_;
  $self->provisional(1);
  return;
}

=head2 fetch_comments

=cut

sub fetch_comments
{
  my ($self) = @_;
  my $path = $self->path_to_GFF;
  open (my $FILE, '<', $path) || $self->throw("Can't find $path: $OS_ERROR\n");
  my $ref = do {local $/ = <$FILE>};
  close $FILE;
  my @lines = split m{\n}, $ref;
  my @precomments = grep {$_ =~ m{^\# [^\#.]+ }msx} @lines;
  my @comments = map {$_ . "\n"} @precomments;
  return \@comments;
}

=head2 fetch_features

=cut

sub fetch_features
{
  my ($self, @args) = @_;
  my ($type, $name)
    = $self->_rearrange([qw(
        type
        name)], @args
  );
  if ($type && $name)
  {
    return $self->db->features(
      -seq_id => $self->seq_id(),
      -type => $type,
      -name => $name,
    );
  }
  if ($type)
  {
    return $self->db->get_features_by_type($type);
  }
  if ($name)
  {
    my @res = $self->db->get_feature_by_name($name);
    return $res[0];
  }
  else
  {
    return $self->db->get_all_features();
  }
}

=head2 add_feature

=cut

sub add_feature
{
  my ($self, @args) = @_;

  my ($f, $atts, $comments, $source)
    = $self->_rearrange([qw(
        feature
        attributes
        comments
        source)], @args
  );

  $self->throw('no feature to add!') unless ($f);
  
  $self->throw('argument to comments is not array reference')
    if ($comments && ref $comments ne 'ARRAY');



( run in 0.534 second using v1.01-cache-2.11-cpan-af0e5977854 )