Permalink
Browse files

Merge pull request #53 from bvaisvil/master

replace "new Class" with "Class->new()" per Perl Best Practices.
  • Loading branch information...
carandraug committed Mar 12, 2013
2 parents d5c7e75 + e3a770c commit 2f35affbf3024c8da78a21a34620ac10d3cc4a2e
@@ -132,7 +132,7 @@ sub _initialize {
# create an instance of the XML parser
# (unless it is already there...)
- $self->{'_xml_parser'} = new XML::Parser (Handlers => {Init => \&handle_doc_start,
+ $self->{'_xml_parser'} = XML::Parser->new (Handlers => {Init => \&handle_doc_start,
Start => \&handle_start,
End => \&handle_end,
Char => \&handle_char,
@@ -127,7 +127,7 @@ sub _initialize {
# create an instance of the XML parser
# (unless it is already there...)
- $self->{'_xml_parser'} = new XML::Parser (Handlers => {Init => \&Bio::Biblio::IO::medlinexml::handle_doc_start,
+ $self->{'_xml_parser'} = XML::Parser->new (Handlers => {Init => \&Bio::Biblio::IO::medlinexml::handle_doc_start,
Start => \&handle_start,
End => \&handle_end,
Char => \&Bio::Biblio::IO::medlinexml::handle_char,
@@ -1172,7 +1172,7 @@ sub len {
sub clone {
local $_;
my $self = shift;
- my $ret = new QRY();
+ my $ret = QRY->new();
foreach ($self->requests) {
$ret->put_requests($_->clone);
}
@@ -1346,7 +1346,7 @@ by an R object are effectively C<AND>ed.
package # hide from PAUSE
R;
use strict;
-$R::NULL = new R();
+$R::NULL = R->new();
## R constructor
@@ -1538,7 +1538,7 @@ sub A {
sub clone {
local $_;
my $self = shift;
- my $ret = new R();
+ my $ret = R->new();
foreach ($self->atoms) {
$ret->put_atoms($_->clone);
}
@@ -1602,7 +1602,7 @@ sub And {
# common fields
my @cf = grep {defined} map {my $sf = $_; grep /$sf/, $t->fields } $s->fields;
- my $ret = new R();
+ my $ret = R->new();
my $v = $t->clone;
$v->del_atoms(@cf);
my $u = $s->clone;
@@ -1729,7 +1729,7 @@ C<qeq, qin, qand, qor>.
package # hide from PAUSE
Q;
use strict;
-$Q::NULL = new Q();
+$Q::NULL = Q->new();
## Q constructor
@@ -1860,7 +1860,7 @@ sub A {
sub clone {
my $self = shift;
Bio::Root::Root->throw("requires type Q (atom)") unless ref($self) && $self->isa('Q');
- my $ret = new Q ($self->fld, $self->dta);
+ my $ret = Q->new($self->fld, $self->dta);
return $ret;
}
@@ -1937,7 +1937,7 @@ sub qor {
foreach my $f (@f) {
my @fobjs = grep {$_->fld eq $f} @a;
my @d = unique(map {split(/\s/, $_->dta)} @fobjs );
- my $r = new Q($f, @d);
+ my $r = Q->new($f, @d);
push @ret, $r;
}
return @ret;
@@ -1983,7 +1983,7 @@ sub qand {
foreach (@bd) {
$ad{$_}++;
}
- my $r = new Q($a->fld,
+ my $r = Q->new($a->fld,
grep {$_}
map {$ad{$_} == 2 ? $_ : undef} keys %ad);
return (length($r->dta) > 0) ? ($r) : ($Q::NULL);
@@ -2109,8 +2109,8 @@ sub put_value {
else {
# replace an old value
$self->remove_Annotations($_) if $a;
- my $ac = new Bio::Annotation::Collection;
- $self->add_Annotation(new Bio::Annotation::SimpleValue(
+ my $ac = Bio::Annotation::Collection->new();
+ $self->add_Annotation(Bio::Annotation::SimpleValue->new(
-tagname => $_,
-value => $ac
)
@@ -2123,7 +2123,7 @@ sub put_value {
($self->get_Annotations($lastkey))[0]->{value} = $value;
}
else {
- $self->add_Annotation(new Bio::Annotation::SimpleValue(
+ $self->add_Annotation(Bio::Annotation::SimpleValue->new(
-tagname=>$lastkey,
-value=>$value
));
View
@@ -401,7 +401,7 @@ sub help{
my ($self, $fname) = @_;
my (@ret, @tok);
my $schema = $self->_schema;
- my $h = new CGI;
+ my $h = CGI->new();
my (@tbls, @flds, @als, @opts, $fh);
if ($fname) {
@@ -531,7 +531,7 @@ sub add_annotations_for_id{
my $self = shift;
my ($id, $ac) = @_;
$id = "" unless defined $id; # avoid warnings
- $ac = new Bio::Annotation::Collection unless defined $ac;
+ $ac = Bio::Annotation::Collection->new() unless defined $ac;
$self->throw(-class=>'Bio::Root::BadParameter'
-text=>'Bio::Annotation::Collection required at arg 2',
-value=>"") unless ref($ac) eq 'Bio::Annotation::Collection';
@@ -1345,7 +1345,7 @@ sub _do_lanl_request {
eval { # encapsulate communication errors here, defer biothrows...
#mark the useragent should be setable from outside (so we can modify timeouts, etc)
- my $ua = new Bio::WebAgent($self->_ua_hash);
+ my $ua = Bio::WebAgent->new($self->_ua_hash);
my $idPing = $ua->get($self->_map_db_uri);
$idPing->is_success || do {
$response=$idPing;
@@ -1484,7 +1484,7 @@ sub _parse_lanl_response {
@rec{@cols} = split /\t/;
my $id = $rec{'se_id'};
$self->add_id($id);
- $ac = new Bio::Annotation::Collection();
+ $ac = Bio::Annotation::Collection->new();
#create annotations
foreach (@cols) {
next if $_ eq '#';
View
@@ -122,7 +122,7 @@ sub new {
$self->query($query);
$verbose && $self->verbose($verbose);
- my $ua = new LWP::UserAgent(env_proxy => 1);
+ my $ua = LWP::UserAgent->new(env_proxy => 1);
$ua->agent(ref($self) ."/".($Bio::DB::Query::WebQuery::VERSION || '0.1'));
$self->ua($ua);
$self->{'_authentication'} = [];
@@ -393,7 +393,7 @@ sub get_matrix {
my $g_freq = ($seq =~ tr/g//) / length($seq);
my $t_freq = ($seq =~ tr/t//) / length($seq);
- my $psm = new Bio::Matrix::PSM::SiteMatrix( -pA => $a,
+ my $psm = Bio::Matrix::PSM::SiteMatrix->new(-pA => $a,
-pC => $c,
-pG => $g,
-pT => $t,
@@ -638,7 +638,7 @@ sub get_factor {
#*** not always relative to gene start...
# we need Bio::Map::Gene s to have some default tss and atg positions
# that we can be relative to
- my $rel = new Bio::Map::Relative(-element => $gene_map->gene, -description => $s_data[3]);
+ my $rel = Bio::Map::Relative->new(-element => $gene_map->gene, -description => $s_data[3]);
Bio::Map::Position->new(-map => $gene_map, -element => $tf, -start => $s_data[4], -end => $s_data[5], -relative => $rel);
}
View
@@ -131,7 +131,7 @@ sub new {
$format ne '' );
$self->request_format($format);
- my $ua = new LWP::UserAgent(env_proxy => 1);
+ my $ua = LWP::UserAgent->new(env_proxy => 1);
$ua->agent(ref($self) ."/$MODVERSION");
$self->ua($ua);
$self->{'_authentication'} = [];
View
@@ -193,7 +193,7 @@ sub fetch_report
}
# Then join them and send
- my $rfh = new IO::String(join('', @header, @data));
+ my $rfh = IO::String->new(join('', @header, @data));
my $report = Bio::SearchIO->new(
-noclose => 1,
-format => 'hmmer',
View
@@ -389,7 +389,7 @@ sub create_bperl_seq {
else {$seqID = $rowlabel;}
#build the seq object using the factory create method
- my $seqbuilder = new Bio::Seq::SeqFactory('-type' => 'Bio::Seq');
+ my $seqbuilder = Bio::Seq::SeqFactory->new('-type' => 'Bio::Seq');
my $seq = $seqbuilder->create(
-seq => $newSeq,
-id => $rowlabel,
View
@@ -889,7 +889,7 @@ sub create_filehandle {
}
require FileHandle;
- $FH = new FileHandle;
+ $FH = FileHandle->new();
open ($FH, $file) || $self->throw(-class=>'Bio::Root::FileOpenException',
-text =>"Can't access data file: $file: $!");
$self->verbose > 0 and printf STDERR "$ID: reading data from file $file\n";
View
@@ -1517,8 +1517,8 @@ sub _write_each_record {
my ($self,$seq) = @_;
# $self->{'file'} =~ s/>//g;
- my $output = new IO::File(">" . $self->{'file'});
- my $writer = new XML::Writer(OUTPUT => $output,
+ my $output = IO::File->new(">" . $self->{'file'});
+ my $writer = XML::Writer->new(OUTPUT => $output,
NAMESPACES => 0,
DATA_MODE => 1,
DATA_INDENT => 2 ) ;
View
@@ -1420,7 +1420,7 @@ sub _parse_xml {
$self->throw("Could not parse non-existant XML file '$file'.");
return;
}
- my $parser = new XML::DOM::Parser;
+ my $parser = XML::DOM::Parser->new();
my $doc = $parser->parsefile ($file);
return $doc;
}
View
@@ -1779,9 +1779,9 @@ sub next_seq {
sub _create_writer {
my $self = shift;
- $self->{'writer'} = new XML::Writer(OUTPUT => $self->_fh,
- DATA_MODE => 1,
- DATA_INDENT => 3);
+ $self->{'writer'} = XML::Writer->new(OUTPUT => $self->_fh,
+ DATA_MODE => 1,
+ DATA_INDENT => 3);
#print header
$self->{'writer'}->xmlDecl("UTF-8");
View
@@ -1164,7 +1164,7 @@ sub _process_grif {
$refergene = $grif->{source}->{src}->{tag}->{id};
$refdb = $grif->{source}->{src}->{db};
}
- my $grifobj = new Bio::Annotation::Comment( -text => $grif->{text} );
+ my $grifobj = Bio::Annotation::Comment->new( -text => $grif->{text} );
$obj = Bio::Annotation::DBLink->new(
-database => 'generif',
-primary_id => $ref->{pmid}
@@ -1177,7 +1177,7 @@ sub _process_grif {
$type = 'dblink';
}
else {
- $obj = new Bio::Annotation::SimpleValue( $grif->{text}, 'generif' );
+ $obj = Bio::Annotation::SimpleValue->new( $grif->{text}, 'generif' );
$type = 'generif';
}
delete $grif->{text};
View
@@ -161,7 +161,7 @@ sub start_element {
$self->sequence_factory->create();
} elsif( $name eq 'GBFEATURE' ) {
my $curseq = $self->{'_seendata'}->{'_seqs'}->[-1];
- my $fthelper = new Bio::SeqIO::FTHelper();
+ my $fthelper = Bio::SeqIO::FTHelper->new();
$fthelper->verbose($self->verbose());
push @{$self->{'_seendata'}->{'_feats'}}, $fthelper;
}
View
@@ -449,7 +449,7 @@ sub next_seq {
# Project
elsif (/^PROJECT\s+(\S.*)/) {
if ($annotation) {
- my $project = new Bio::Annotation::SimpleValue->new(-value => $1);
+ my $project = Bio::Annotation::SimpleValue->new(-value => $1);
$annotation->add_Annotation('project',$project);
}
}
View
@@ -81,7 +81,7 @@ use Bio::Annotation::Collection;
use Bio::Annotation::Comment;
use Dumpvalue;
-my $dumper = new Dumpvalue();
+my $dumper = Dumpvalue->new();
use base qw(Bio::SeqIO);
View
@@ -83,7 +83,7 @@ use strict;
use Bio::Seq::SeqFactory;
use Dumpvalue;
-my $dumper = new Dumpvalue();
+my $dumper = Dumpvalue->new();
use base qw(Bio::SeqIO);
View
@@ -83,7 +83,7 @@ use Bio::Seq::SequenceTrace;
use Bio::Annotation::Comment;
use Dumpvalue;
-my $dumper = new Dumpvalue();
+my $dumper = Dumpvalue->new();
$dumper->veryCompact(1);
BEGIN {
View
@@ -95,7 +95,7 @@ use Convert::Binary::C;
use base qw(Bio::SeqIO);
-my $c = new Convert::Binary::C (
+my $c = Convert::Binary::C->new (
ByteOrder => 'BigEndian',
Alignment => 2
);
@@ -1508,7 +1508,7 @@ sub get_doublets {
sub dump_hash {
my $self = shift;
- my $dumper = new Dumpvalue;
+ my $dumper = Dumpvalue->new();
$self->debug( "Bio::Tools::Alignment::Consed::dump_hash - ".
"The following is the contents of the contig hash...\n");
$dumper->dumpValue($self->{'contigs'});
@@ -205,7 +205,7 @@ sub _init {
sub _run {
my $self = shift;
my $seq_fasta;
- my $stringfh = new IO::String($seq_fasta);
+ my $stringfh = IO::String->new($seq_fasta);
my $seqout = Bio::SeqIO->new(-fh => $stringfh,
-format => 'fasta');
$seqout->write_seq($self->seq);
@@ -266,7 +266,7 @@ sub _run {
# format the sequence into fasta
my $seq_fasta;
- my $stringfh = new IO::String($seq_fasta);
+ my $stringfh = IO::String->new($seq_fasta);
my $seqout = Bio::SeqIO->new(-fh => $stringfh,
-format => 'fasta');
$seqout->write_seq($self->seq);
View
@@ -1091,7 +1091,7 @@ sub _parse_Forestry {
}
elsif (/^\(/) {
s/([\,:])\s+/$1/g;
- my $treestr = new IO::String($_);
+ my $treestr = IO::String->new($_);
my $treeio = Bio::TreeIO->new(
-fh => $treestr,
-format => 'newick'
@@ -241,8 +241,8 @@ sub _parse_mlc {
# ...
while( defined($_ = $self->_readline) ) {
if( /^\(/) {
- my $treestr = new IO::String($_);
- my $treeio = new Bio::TreeIO(-fh => $treestr,
+ my $treestr = IO::String->new($_);
+ my $treeio = Bio::TreeIO->new(-fh => $treestr,
-format => 'newick');
# this is very tenative here!!
push @{$self->{'_trees'}}, $treeio->next_tree;
View
@@ -518,7 +518,7 @@ sub revcom {
# $self->{'_rev'} = $fixrev;
- return new Bio::Tools::SeqPattern(-seq =>$fixrev, -type =>$self->type);
+ return Bio::Tools::SeqPattern->new(-seq =>$fixrev, -type =>$self->type);
}
=head1 backtranslate
View
@@ -227,7 +227,7 @@ sub next {
# create new parser object
my $twig_handlers = {'seqDiff' => \&_seqDiff };
- my $t = new XML::Twig ( TwigHandlers => $twig_handlers,
+ my $t = XML::Twig->new ( TwigHandlers => $twig_handlers,
KeepEncoding => 1 );
$t->parse($entry);
@@ -252,7 +252,7 @@ sub write {
}
my $str;
my $output = IO::String->new($str);
- my $w = new XML::Writer(OUTPUT => $output, DATA_MODE => 1, DATA_INDENT => 4 );
+ my $w = XML::Writer->new(OUTPUT => $output, DATA_MODE => 1, DATA_INDENT => 4 );
foreach my $h (@h) {
#

0 comments on commit 2f35aff

Please sign in to comment.