Bio-FeatureIO
view release on metacpan or search on metacpan
lib/Bio/FeatureIO.pm view on Meta::CPAN
300301302303304305306307308309310311312313314315316317318319320321322323324325326
my
(
$self
) =
$class
->SUPER::new(
@args
);
$self
->_initialize(
@args
);
return
$self
;
}
else
{
my
%param
=
@args
;
@param
{
map
{
lc
$_
}
keys
%param
} =
values
%param
;
# lowercase keys
my
$format
=
$param
{
'-format'
} ||
$class
->_guess_format(
$param
{-file} ||
$ARGV
[0] );
if
( !
$format
) {
if
(
$param
{-file}) {
$format
=
$class
->_guess_format(
$param
{-file});
}
elsif
(
$param
{-fh}) {
$format
=
$class
->_guess_format(
undef
);
}
}
$format
=
"\L$format"
;
# normalize capitalization to lower case
return
unless
(
$class
->_load_format_module(
$format
) );
return
"Bio::FeatureIO::$format"
->new(
@args
);
}
}
=head2 newFh
lib/Bio/FeatureIO.pm view on Meta::CPAN
483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514Args : newvalue (optional)
=cut
sub _filehandle {
my ($self,@args) = @_;
return $self->_fh(@args);
}
=head2 _guess_format
Title : _guess_format
Usage : $obj->_guess_format($filename)
Function: guess format based on file suffix
Example :
Returns : guessed format of filename (lower case)
Args :
Notes : See "SUPPORTED FORMATS"
=cut
sub
_guess_format {
my
$class
=
shift
;
return
unless
$_
=
shift
;
return
'gff'
if
/\.gff3?$/i;
return
'gff'
if
/\.gtf$/i;
return
'bed'
if
/\.bed$/i;
return
'ptt'
if
/\.ptt$/i;
return
'gff'
;
#the default
}
lib/Bio/FeatureIO/gff.pm view on Meta::CPAN
665666667668669670671672673674675676677678679680681682683684685
$feat
->add_Annotation(
'Dbxref'
,
$a
);
}
}
#Handle Ontology_term attributes
if
(
$attr
{Ontology_term}){
foreach
my
$id
(@{
$attr
{Ontology_term} }){
my
$a
= Bio::Annotation::OntologyTerm->new();
if
(
$self
->validate()){
my
$ont_name
= Bio::Ontology::OntologyStore->guess_ontology(
$id
);
my
$ont
= Bio::Ontology::OntologyStore->get_ontology(
$ont_name
);
my
(
$term
) =
$ont
->find_terms(
-identifier
=>
$id
);
$a
->term(
$term
);
}
else
{
$a
->identifier(
$id
);
}
$feat
->add_Annotation(
'Ontology_term'
,
$a
);
}
}
( run in 0.323 second using v1.01-cache-2.11-cpan-e5176c747c2 )