$Bio::EnsEMBL::IdentityXref::VERSION
=
'112.0_55'
;
$Bio::EnsEMBL::IdentityXref::VERSION
=
'112.055'
;
use
vars
qw(@ISA $AUTOLOAD)
;
@ISA
=
qw( Bio::EnsEMBL::DBEntry )
;
my
$error_shown
= 0;
sub
new {
my
(
$class
,
@args
) =
@_
;
my
$self
=
$class
->SUPER::new(
@args
);
my
(
$query_identity
,
$target_identity
,
$score
,
$evalue
,
$cigar_line
,
$query_start
,
$query_end
,
$translation_start
,
$translation_end
,
$analysis
,
$xref_identity
,
$ensembl_identity
,
$xref_start
,
$xref_end
,
$ensembl_start
,
$ensembl_end
) = rearrange(
[
qw(QUERY_IDENTITY TARGET_IDENTITY SCORE EVALUE CIGAR_LINE
QUERY_START QUERY_END TRANSLATION_START TRANSLATION_END
ANALYSIS XREF_IDENTITY ENSEMBL_IDENTITY XREF_START XREF_END ENSEMBL_START ENSEMBL_END)
],
@args
);
if
((
defined
(
$query_identity
) or
defined
(
$target_identity
) or
defined
(
$query_start
) or
defined
(
$query_end
) or
defined
(
$translation_start
) or
defined
(
$translation_end
)) and !
$error_shown
){
print
STDERR
"Arguments have now been changed to stop confusion so please replace the following\n"
;
print
STDERR
"\tQUERY_IDENTITY\t->\tXREF_IDENTITY\n"
;
print
STDERR
"\tTARGET_IDENTITY\t->\tENSEMBL_IDENTITY\n"
;
print
STDERR
"\tQUERY_START\t->\tXREF_START\n"
;
print
STDERR
"\tQUERY_END\t->\tXREF_END\n"
;
print
STDERR
"\tTRANSLATION_START\t->\tENSEMBL_START\n"
;
print
STDERR
"\tTRANSLATION_END\t->\tENSEMBL_END\n"
;
print
STDERR
"The old arguments will be removed in a futute release so please change your code to the new names\n"
;
$error_shown
= 1;
}
$self
->{
'xref_identity'
} =
$query_identity
||
$xref_identity
;
$self
->{
'ensembl_identity'
} =
$target_identity
||
$ensembl_identity
;
$self
->{
'score'
} =
$score
;
$self
->{
'evalue'
} =
$evalue
;
$self
->{
'cigar_line'
} =
$cigar_line
;
$self
->{
'xref_start'
} =
$query_start
||
$xref_start
;
$self
->{
'xref_end'
} =
$query_end
||
$xref_end
;
$self
->{
'ensembl_start'
} =
$translation_start
||
$ensembl_start
;
$self
->{
'ensembl_end'
} =
$translation_end
||
$ensembl_end
;
$self
->{
'analysis'
} =
$analysis
;
return
$self
;
}
sub
xref_identity{
my
$obj
=
shift
;
if
(
@_
) {
my
$value
=
shift
;
$obj
->{
'xref_identity'
} =
$value
;
}
return
$obj
->{
'xref_identity'
};
}
sub
ensembl_identity{
my
$obj
=
shift
;
if
(
@_
) {
my
$value
=
shift
;
$obj
->{
'ensembl_identity'
} =
$value
;
}
return
$obj
->{
'ensembl_identity'
};
}
sub
cigar_line {
my
$self
=
shift
;
$self
->{
'cigar_line'
} =
shift
if
(
@_
);
return
$self
->{
'cigar_line'
};
}
sub
ensembl_start {
my
$self
=
shift
;
$self
->{
'ensembl_start'
} =
shift
if
(
@_
);
return
$self
->{
'ensembl_start'
};
}
sub
ensembl_end {
my
$self
=
shift
;
$self
->{
'ensembl_end'
} =
shift
if
(
@_
);
return
$self
->{
'ensembl_end'
};
}
sub
xref_start {
my
$self
=
shift
;
$self
->{
'xref_start'
} =
shift
if
(
@_
);
return
$self
->{
'xref_start'
};
}
sub
xref_end {
my
$self
=
shift
;
$self
->{
'xref_end'
} =
shift
if
(
@_
);
return
$self
->{
'xref_end'
};
}
sub
score {
my
$self
=
shift
;
$self
->{
'score'
} =
shift
if
(
@_
);
return
$self
->{
'score'
};
}
sub
evalue {
my
$self
=
shift
;
$self
->{
'evalue'
} =
shift
if
(
@_
);
return
$self
->{
'evalue'
};
}
sub
get_mapper {
my
(
$self
) =
@_
;
if
(
exists
$self
->{
'_cached_mapper'
} ) {
return
$self
->{
'_cached_mapper'
};
}
my
(
@lens
,
@chars
);
if
(
$self
->cigar_line() ) {
my
@pre_lens
=
split
(
'[DMI]'
,
$self
->cigar_line() );
@lens
=
map
{
if
( !
$_
) { 1 }
else
{
$_
}}
@pre_lens
;
@chars
=
grep
{ /[DMI]/ }
split
( //,
$self
->cigar_line() );
}
my
$translation_start
=
$self
->ensembl_start();
my
$translation_end
=
$self
->ensembl_end();
my
$query_start
=
$self
->xref_start();
my
$query_end
=
$self
->xref_end();
my
$ensembl_id
=
"ensembl_id"
;
my
$external_id
=
"external_id"
;
my
$mapper
= Bio::EnsEMBL::Mapper->new(
"external"
,
"ensembl"
);
for
(
my
$i
=0;
$i
<=
$#lens
;
$i
++ ) {
my
$length
=
$lens
[
$i
];
my
$char
=
$chars
[
$i
];
if
(
$char
eq
"M"
) {
$mapper
->add_map_coordinates(
$external_id
,
$query_start
,
$query_start
+
$length
- 1, 1,
$ensembl_id
,
$translation_start
,
$translation_start
+
$length
- 1);
$query_start
+=
$length
;
$translation_start
+=
$length
;
}
elsif
(
$char
eq
"D"
) {
$translation_start
+=
$length
;
}
elsif
(
$char
eq
"I"
) {
$query_start
+=
$length
;
}
}
$self
->{
'_cached_mapper'
} =
$mapper
;
return
$mapper
;
}
sub
transform_feature {
my
$self
=
shift
;
my
$feature
=
shift
;
my
$fstart
=
$feature
->start();
my
$fend
=
$feature
->end();
my
$mapper
=
$self
->get_mapper();
my
@result
;
my
@coords
=
$mapper
->map_coordinates(
"external_id"
,
$fstart
,
$fend
,
1,
"external"
);
for
my
$coord
(
@coords
) {
if
(
$coord
->isa(
"Bio::EnsEMBL::Mapper::Coordinate"
)) {
my
$new_feature
;
%{
$new_feature
} =
%$feature
;
bless
$new_feature
,
ref
(
$feature
);
$new_feature
->start(
$coord
->start() );
$new_feature
->end(
$coord
->end() );
push
(
@result
,
$new_feature
);
}
}
return
\
@result
;
}
sub
map_feature {
my
$self
=
shift
;
my
$feature
=
shift
;
my
$fstart
=
$feature
->start();
my
$fend
=
$feature
->end();
my
$mapper
=
$self
->get_mapper();
my
@coords
=
$mapper
->map_coordinates(
"external_id"
,
$fstart
,
$fend
, 1,
"external"
);
return
@coords
;
}
1;