Bio-EnsEMBL
view release on metacpan or search on metacpan
CONTRIBUTING.md view on Meta::CPAN
# Contribution Guide
The Ensembl development team welcomes outside contributions, in fact we moved to Git to facilitate this. However, to ensure legibility for other users, we ask contributors to take a few moments to clean up their code, its comments, and its history be...
This guide covers how to contribute changes to an Ensembl project. Please do not create a pull request without reading this guide first.
We also invite you to read our code of conduct (http://www.ensembl.org/info/about/code_of_conduct.html) before continuing.
## Quick Guide - Using Forks & Pull Requests
1. Fork the ensembl repository
2. Switch to the branch you want to edit
* Consider using feature branches over editing main
3. Hack away and commit with a useful commit message
lib/Bio/EnsEMBL/Utils/AssemblyProjector.pm view on Meta::CPAN
=head1 DESCRIPTION
This class implements some utility functions for converting coordinates
between assemblies. A mapping between the two assemblies has to present
the database for this to work, see the 'Related Modules' section below
on how to generate the mapping.
In addition to the "raw" projecting of features and slices, the methods
in this module also apply some sensible rules to the results of the
projection (like discarding unwanted results or merging fragmented
projections). These are the rules (depending on configuration):
Discard the projected feature/slice if:
1. it doesn't project at all (no segments returned)
2. [unless MERGE_FRAGMENTS is set] the projection is fragmented (more
than one segment)
3. [if CHECK_LENGTH is set] the projection doesn't have the same
length as the original feature/slice
4. all segments are on same chromosome and strand
If a projection fails any of these rules, undef is returned instead of
a projected feature/slice. You can use the last_status() method to find
out about the results of the rules tests.
Also note that when projecting features, only a shallow projection is
lib/Bio/EnsEMBL/Utils/AssemblyProjector.pm view on Meta::CPAN
=head1 METHODS
new
project
old_to_new
new_to_old
adaptor
external_source
old_assembly
new_assembly
merge_fragments
check_length
=head1 RELATED MODULES
The process of creating a whole genome alignment between two assemblies
(which is the basis for the use of the methods in this class) is done by
a series of scripts. Please see
ensembl/misc-scripts/assembly/README
lib/Bio/EnsEMBL/Utils/AssemblyProjector.pm view on Meta::CPAN
Status : At Risk
: under development
=cut
sub new {
my $caller = shift;
my $class = ref($caller) || $caller;
my ($adaptor, $external_source, $old_assembly, $new_assembly,
$merge_fragments, $check_length) = rearrange([qw(ADAPTOR EXTERNAL_SOURCE
OLD_ASSEMBLY NEW_ASSEMBLY MERGE_FRAGMENTS CHECK_LENGTH)], @_);
unless ($adaptor and ref($adaptor) and
$adaptor->isa('Bio::EnsEMBL::DBSQL::DBAdaptor')) {
throw("You must provide a DBAdaptor to a database containing the assembly mapping.");
}
unless ($old_assembly and $new_assembly) {
throw("You must provide an old and new assembly name.");
}
my $self = {};
bless ($self, $class);
# initialise
$self->adaptor($adaptor);
$self->{'old_assembly'} = $old_assembly;
$self->{'new_assembly'} = $new_assembly;
# by default, merge fragments
$self->{'merge_fragments'} = $merge_fragments || 1;
# by default, do not check length
$self->{'check_length'} = $check_length || 0;
# by default, features and slices are expected in same database as the
# assembly mapping
$self->{'external_source'} = $external_source || 0;
return $self;
}
lib/Bio/EnsEMBL/Utils/AssemblyProjector.pm view on Meta::CPAN
# we need to reverse the projection segment list if the orignial
if ($slice->strand == -1) {
@segments = reverse(@segments);
}
# apply rules to projection results
#
# discard the projected feature/slice if
# 1. it doesn't project at all (no segments returned)
# 2. [unless MERGE_FRAGMENTS is set] the projection is fragmented (more
# than one segment)
# 3. [if CHECK_LENGTH is set] the projection doesn't have the same length
# as the original feature/slice
# 4. all segments are on same chromosome and strand
# keep track of the status of applied rules
my @status = ();
# test (1)
return undef unless (@segments);
#warn "DEBUG: passed test 1\n";
# test (2)
return undef if (!($self->merge_fragments) and scalar(@segments) > 1);
push @status, 'fragmented' if (scalar(@segments) > 1);
#warn "DEBUG: passed test 2\n";
# test (3)
my $first_slice = $segments[0]->to_Slice;
my $last_slice = $segments[-1]->to_Slice;
my $length_mismatch = (($last_slice->end - $first_slice->start + 1) !=
$object->length);
return undef if ($self->check_length and $length_mismatch);
push @status, 'length_mismatch' if ($length_mismatch);
#warn "DEBUG: passed test 3\n";
lib/Bio/EnsEMBL/Utils/AssemblyProjector.pm view on Meta::CPAN
}
sub new_assembly {
my $self = shift;
$self->{'new_assembly'} = shift if (@_);
return $self->{'new_assembly'};
}
sub merge_fragments {
my $self = shift;
$self->{'merge_fragments'} = shift if (@_);
return $self->{'merge_fragments'};
}
sub check_length {
my $self = shift;
$self->{'check_length'} = shift if (@_);
return $self->{'check_length'};
}
lib/Bio/EnsEMBL/Utils/VegaCuration/Transcript.pm view on Meta::CPAN
=cut
sub check_remarks_and_update_names {
my $self = shift;
my ($gene,$gene_c,$trans_c) = @_;
my $action = ($self->param('dry_run')) ? 'Would add' : 'Added';
my $aa = $gene->adaptor->db->get_AttributeAdaptor;
my $dbh = $gene->adaptor->db->dbc->db_handle;
#get list of IDs that have previously been sent to annotators
my $seen_genes = $self->get_havana_fragmented_loci_comments;
my $gsi = $gene->stable_id;
my $gid = $gene->dbID;
my $g_name;
my $study_more = 1;
eval {
$g_name = $gene->display_xref->display_id;
};
if ($@) {
$g_name = $gene->get_all_Attributes('name')->[0]->value;
}
#get existing gene remarks
my $remarks = [ map {$_->value} @{$gene->get_all_Attributes('remark')} ];
#shout if there is no remark to identify this as being fragmented
if ( grep {$_ eq 'fragmented locus' } @$remarks) {
$study_more = 0;
}
else {
$self->log_warning("Gene $gsi should have a fragmented locus remark\n");
}
##patch transcript names according to length and CDS
$gene_c++;
#separate coding and non_coding transcripts
my $coding_trans = [];
my $noncoding_trans = [];
foreach my $trans ( @{$gene->get_all_Transcripts()} ) {
if ($trans->translate) {
lib/Bio/EnsEMBL/Utils/VegaCuration/Transcript.pm view on Meta::CPAN
}
#if the transcripts don't overlap
elsif (@{$non_overlaps}) {
my $tsi_string;
foreach my $id (@{$non_overlaps}) {
my $string = " $id [ $ids_to_names{$id} ] ";
$tsi_string .= $string;
}
$self->log_warning("NEW: Non-overlapping: $gsi ($g_name) has non-overlapping transcripts ($tsi_string) with duplicated Vega names, and it has no \'fragmented locus\' gene remark. Neither has it been OKeyed by Havana before. Transcript names are...
#log gsi (to be sent to Havana)
print $n_flist_fh "$gsi\n";
}
#...otherwise if the transcripts do overlap
else {
$self->log_warning("NEW: Overlapping: $gsi ($g_name) has overlapping transcripts ($all_t_names) with duplicated Vega names and it has no \'fragmented locus\' gene_remark. Neither has it been OKeyed by Havana before. Transcript names are being p...
print $n_flist_fh "$gsi\n";
}
}
}
=head2 get_havana_fragmented_loci_comments
Args : none
Example : my $results = $support->get_havana_fragmented_loci_comments
Description: parses the HEREDOC containing Havana comments in this module
Returntype : hashref
=cut
sub get_havana_fragmented_loci_comments {
my $seen_genes;
while (<DATA>) {
next if /^\s+$/ or /#+/;
my ($obj,$comment) = split /=/;
$obj =~ s/^\s+|\s+$//g;
$comment =~ s/^\s+|\s+$//g;
$seen_genes->{$obj} = $comment;
}
return $seen_genes;
}
#details of genes with duplicated transcript names that have already been reported to Havana
#identified as either fragmented or as being OK to patch
__DATA__
OTTMUSG00000005478 = fragmented
OTTMUSG00000001936 = fragmented
OTTMUSG00000017081 = fragmented
OTTMUSG00000011441 = fragmented
OTTMUSG00000013335 = fragmented
OTTMUSG00000011654 = fragmented
OTTMUSG00000001835 = fragmented
OTTHUMG00000035221 = fragmented
OTTHUMG00000037378 = fragmented
OTTHUMG00000060732 = fragmented
OTTHUMG00000132441 = fragmented
OTTHUMG00000031383 = fragmented
OTTHUMG00000012716 = fragmented
OTTHUMG00000031102 = fragmented
OTTHUMG00000148816 = fragmented
OTTHUMG00000149059 = fragmented
OTTHUMG00000149221 = fragmented
OTTHUMG00000149326 = fragmented
OTTHUMG00000149644 = fragmented
OTTHUMG00000149574 = fragmented
OTTHUMG00000058101 = fragmented
OTTHUMG00000150119 = OK
OTTHUMG00000149850 = OK
OTTHUMG00000058101 = OK
OTTHUMG00000058907 = OK
OTTMUSG00000011654 = fragmented
OTTMUSG00000019369 = fragmented
OTTMUSG00000017081 = fragmented
OTTMUSG00000001835 = fragmented
OTTMUSG00000011499 = fragmented
OTTMUSG00000013335 = fragmented
OTTMUSG00000008023 = fragmented
OTTMUSG00000019369 = fragmented
OTTMUSG00000022266
OTTMUSG00000006697
OTTMUSG00000012302 =
( run in 0.759 second using v1.01-cache-2.11-cpan-364913b4093 )