<commit_before># Author: <NAME> (<EMAIL>)
# Copyright (c) <NAME>, 2001
# You may distribute this code under the same terms as perl itself
#
# You may distribute this module under the same terms as perl itself
#
# POD documentation - main docs before the code


=head1 NAME

  Bio::EnsEMBL::Pipeline::DBSQL::ProteinFeatureAdaptor - Object representing an adaptor
                                                         for protein features to an EnsEMBL DB

=head1 SYNOPSIS

  use Bio::EnsEMBL::DBSQL::Protein::DBAdaptor;
  use Bio::EnsEMBL::Pipeline::DBSQL::Protein::ProteinFeatureAdaptor;

  my $db = Bio::EnsEMBL::Pipeline::DBSQL::Protein::DBAdaptor->new ( -host   => 'ics1e',
                                                                    -dbname => 'test',
                                                                    -user   => 'marc',
                                                                    -pass   => '<PASSWORD>',
                                                         );               

  my $proteinFeatureAdaptor = $db->get_ProteinFeatureAdaptor;
  my $proteinFeature = $proteinFeatureAdaptor->fetch_Feature_by_dbid ($id);


=head1 DESCRIPTION

  This Object inherits from BaseAdaptor, following the new adaptor rules.
  The main method is fetch_Feature_by_dbid, which returns a complete feature object.


=head1 CONTACT

  <NAME> (<EMAIL>)

=head1 APPENDIX

  The rest of the documentation details each of the object methods.
  Internal methods are usually preceded with a _.

=cut

# Let the code begin...

package Bio::EnsEMBL::Pipeline::DBSQL::Protein::ProteinFeatureAdaptor;

use vars qw(@ISA);
use strict;

use Bio::EnsEMBL::DBSQL::BaseAdaptor;
use Bio::EnsEMBL::DBSQL::FeatureAdaptor;
use Bio::EnsEMBL::Analysis;
use Bio::EnsEMBL::FeaturePair;
use Bio::EnsEMBL::SeqFeature;

@ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor);


=head2 store

 Title    : store
 Usage    : $self->store ($proteinId, @features)
 Function : Writes a feature on the genomic sequence of a contig into the database.
            Checks that we have contig_obj, gets its internal_id. Checks that each
            feature_obj has analysis_obj attached, gets analysis_id from it.
            Checks what kind of feature(s) is/are passed in and passes it/them
            further to appropriate _store_blabla function together with contig_internal_id
            and analysis_id
 Example  : 
 Returns  : 
 Args     : array of Bio::EnsEMBL::SeqFeatureI
 Throws   :

=cut

sub store {
    my ($self, @features) = @_;

    # Get AnalysisAdaptor
    my $analysisAdaptor = $self->db->get_AnalysisAdaptor;

    FEATURE:foreach my $feature (@features) { 
        # check that we have got features
        if( ! $feature->isa('Bio::EnsEMBL::SeqFeatureI') ) {
            $self->throw("Feature $feature is not a SeqFeatureI");
        }
        # check that we have Analysis
        my $analysisid;

        if (!defined ($feature->analysis)) {
            $self->throw ("Feature ".$feature->seqname." ". 
                                     $feature->source_tag." ".
                                     $feature->logic_name. 
                          " doesn't have analysis. Can't write to database");
        }
        else {
	    if ($analysisid = $analysisAdaptor->exists ($feature->analysis)) {
	    }
            else {
                $analysisid = $analysisAdaptor->store ($feature->analysis);
	    }
        }
        # check what kind of feature we're dealing with
        if ($feature->isa ('Bio::EnsEMBL::FeaturePairI')) {
            $self->_store_FeaturePair ($feature, $analysisid);
        }<commit_msg>changed store to write_Protein_feature<commit_after># Author: <NAME> (<EMAIL>)
# Copyright (c) <NAME>, 2001
# You may distribute this code under the same terms as perl itself
#
# You may distribute this module under the same terms as perl itself
#
# POD documentation - main docs before the code


=head1 NAME

  Bio::EnsEMBL::Pipeline::DBSQL::ProteinFeatureAdaptor - Object representing an adaptor
                                                         for protein features to an EnsEMBL DB

=head1 SYNOPSIS

  use Bio::EnsEMBL::DBSQL::Protein::DBAdaptor;
  use Bio::EnsEMBL::Pipeline::DBSQL::Protein::ProteinFeatureAdaptor;

  my $db = Bio::EnsEMBL::Pipeline::DBSQL::Protein::DBAdaptor->new ( -host   => 'ics1e',
                                                                    -dbname => 'test',
                                                                    -user   => 'marc',
                                                                    -pass   => '<PASSWORD>',
                                                         );               

  my $proteinFeatureAdaptor = $db->get_ProteinFeatureAdaptor;
  my $proteinFeature = $proteinFeatureAdaptor->fetch_Feature_by_dbid ($id);


=head1 DESCRIPTION

  This Object inherits from BaseAdaptor, following the new adaptor rules.
  The main method is fetch_Feature_by_dbid, which returns a complete feature object.


=head1 CONTACT

  <NAME> (<EMAIL>)

=head1 APPENDIX

  The rest of the documentation details each of the object methods.
  Internal methods are usually preceded with a _.

=cut

# Let the code begin...

package Bio::EnsEMBL::Pipeline::DBSQL::Protein::ProteinFeatureAdaptor;

use vars qw(@ISA);
use strict;

use Bio::EnsEMBL::DBSQL::BaseAdaptor;
use Bio::EnsEMBL::DBSQL::FeatureAdaptor;
use Bio::EnsEMBL::Analysis;
use Bio::EnsEMBL::FeaturePair;
use Bio::EnsEMBL::SeqFeature;

@ISA = qw(Bio::EnsEMBL::DBSQL::BaseAdaptor);


=head2 write_Protein_feature

 Title    : write_Protein_feature
 Usage    : $self->write_Protein_feature (@features)
 Function :
 Example  : 
 Returns  : 
 Args     : array of Bio::EnsEMBL::SeqFeatureI
 Throws   :

=cut

sub write_Protein_feature {
    my ($self, @features) = @_;

    # Get AnalysisAdaptor
    my $analysisAdaptor = $self->db->get_AnalysisAdaptor;

    FEATURE:foreach my $feature (@features) { 
        # check that we have got features
        if( ! $feature->isa('Bio::EnsEMBL::SeqFeatureI') ) {
            $self->throw("Feature $feature is not a SeqFeatureI");
        }
        # check that we have Analysis
        my $analysisid;

        if (!defined ($feature->analysis)) {
            $self->throw ("Feature ".$feature->seqname." ". 
                                     $feature->source_tag." ".
                                     $feature->logic_name. 
                          " doesn't have analysis. Can't write to database");
        }
        else {
	    if ($analysisid = $analysisAdaptor->exists ($feature->analysis)) {
	    }
            else {
                $analysisid = $analysisAdaptor->store ($feature->analysis);
	    }
        }
        # check what kind of feature we're dealing with
        if ($feature->isa ('Bio::EnsEMBL::FeaturePairI')) {
            $self->_store_FeaturePair ($feature, $analysisid);
        }
{'fraction_non_alphanumeric': 0.10511816731912425, 'fraction_numerical': 0.003189792663476874, 'mean_word_length': 2.139736003641329, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5452065', 'n_tokens_mistral': 2037, 'n_tokens_neox': 1893, 'n_words': 531}