BioPerl

 view release on metacpan or  search on metacpan

Bio/FeatureHolderI.pm  view on Meta::CPAN

	confess ref($feat)." is neither a FeatureHolderI nor a SeqFeatureI. ".
	    "Don't know how to flatten.";
    }
    foreach my $sub (@subs) {
	push(@$arrayref,$sub);
	&_add_flattened_SeqFeatures($arrayref,$sub);
    }

}

sub set_ParentIDs_from_hierarchy(){
    # DEPRECATED - use IDHandler
    my $self = shift;
    require "Bio/SeqFeature/Tools/IDHandler.pm";
    Bio::SeqFeature::Tools::IDHandler->new->set_ParentIDs_from_hierarchy($self);
}

sub create_hierarchy_from_ParentIDs(){
    # DEPRECATED - use IDHandler
    my $self = shift;
    require "Bio/SeqFeature/Tools/IDHandler.pm";
    Bio::SeqFeature::Tools::IDHandler->new->create_hierarchy_from_ParentIDs($self);
}



1;

Bio/RangeI.pm  view on Meta::CPAN

    return 1 if $s1 == 0 || $s2 == 0 || $s1 == $s2;
}

# returns true for any strandedness
sub _ignore {
    return 1;
}

# works out what test to use for the strictness and returns true/false
# e.g. $r1->_testStrand($r2, 'strong')
sub _testStrand() {
    my ($r1, $r2, $comp) = @_;
    return 1 unless $comp;
    my $func = $STRAND_OPTIONS{$comp};
    return $r1->$func($r2);
}

=head1 Abstract methods

These methods must be implemented in all subclasses.

Bio/RangeI.pm  view on Meta::CPAN

  Function: Subtract range r2 from range r1
  Args    : arg #1 = a range to subtract from this one (mandatory)
            arg #2 = strand option ('strong', 'weak', 'ignore') (optional)
  Returns : undef if they do not overlap or r2 contains this RangeI,
            or an arrayref of Range objects (this is an array since some
            instances where the subtract range is enclosed within this range
            will result in the creation of two new disjoint ranges)

=cut

sub subtract() {
   my ($self, $range, $so) = @_;
    $self->throw("missing arg: you need to pass in another feature")
      unless $range;
    return unless $self->_testStrand($range, $so);

    if ($self eq "Bio::RangeI") {
	$self = "Bio::Range";
	$self->warn("calling static methods of an interface is
deprecated; use $self instead");
    }

Bio/SeqFeature/Tools/IDHandler.pm  view on Meta::CPAN


GFF3 uses the tags ID and Parent to represent the feature containment
hierarchy; it does NOT use the feature holder tree

This method sets Parent (and ID for any parents not set) based on
feature holder/containement hierarchy, ready for GFF3 output

=cut

# method author: cjm@fruitfly.org
sub set_ParentIDs_from_hierarchy(){
   my $self = shift;
   my ($featholder) = @_;

   # we will traverse the tree of contained seqfeatures
   # (a seqfeature is itself a holder)

   # start with the top-level features
   my @sfs = $featholder->get_SeqFeatures;

   # clear existing parent tags

Bio/SeqIO/tigr.pm  view on Meta::CPAN

=head2 next_seq

 Title   : next_seq
 Usage   : $seq = $stream->next_seq()
 Function: returns the next sequence in the stream
 Returns : Bio::Seq object
 Args    : NONE

=cut

sub next_seq()
{
	my ($self) = @_;
	
	# Check for any more sequences
	return if !defined($self->{_sequences}) or scalar(@{$self->{_sequences}}) < 1;

	# get the next sequence
	my $seq = shift(@{ $self->{_sequences} } );

	# Get the 5' and 3' ends

Bio/SeqIO/tigr.pm  view on Meta::CPAN

	} else {
		$self->throw("Required <ASSEMBLY_SEQUENCE> missing");
	}

	if($line =~ /<\/ASSEMBLY>/o) {
		return;
	}
	$self->throw("Reached the end of <ASSEMBLY>");
}

sub _process_assembly_seq()
{
	my ($self) = @_;
	my $line;
	
	$line = $self->_readline();
	if($line !~ /<ASSEMBLY_SEQUENCE>/o) {
		$self->throw("Bio::SeqIO::tigr::_process_assembly_seq called ".
			     "with no <ASSEMBLY_SEQUENCE> in the stream");
	}

Bio/SeqIO/tigr.pm  view on Meta::CPAN

		} elsif( ($seq) = ( $line =~ /^\s*(\w+)<\/ASSEMBLY_SEQUENCE>\s*$/o) ) {
			push(@chunks, $seq);
			$self->{_assembly}->{seq} = join('', @chunks);
			return;
		}
	} while( $line );

	$self->throw("Reached end of _proces_assembly");
}

sub _process_coordset($)
{
	my ($self) = @_;
	my $line;
	my $h;

	$line = $self->_readline();
	if($line =~ /<COORDSET>/o) {
		$self->_pushback($line);
		$line = $self->_readtag();
		($h->{end5}, $h->{end3}) = ($line =~ /<COORDSET>\s*<END5>\s*(\d+)\s*<\/END5>\s*<END3>\s*(\d+)\s*<\/END3>/os);

Bio/Structure/SecStr/DSSP/Res.pm  view on Meta::CPAN

 Title         : _parseResLine
 Usage         : parses a single residue line
 Function      :
 Example       : used internally
 Returns       :
 Args          : residue line ( string )


=cut

sub _parseResLine() {
    my $cur = shift;
    my ( $feat, $value );
    my %elements;

    foreach $feat ( keys %lookUp ) {
	$value = substr( $cur, $lookUp{ $feat }->[0],
			 $lookUp{ $feat }->[1] );
	$value =~ s/\s//g;
	$elements{$feat} = $value ;
    }

Bio/Tools/Alignment/Consed.pm  view on Meta::CPAN

           phred data.
 Returns : A reference to an array containing reversed phred data.
 Args    : A reference to a source array and a reverence to a destination
	   array.

Recursion is kewl, but this sub should likely be _reverse_recurse.

=cut


sub reverse_recurse($$) {
    my ($r_source,$r_destination) = @_;
    if (!@$r_source) {
        return $r_destination;
    }
    $_=pop(@$r_source);
    s/c/g/ || s/g/c/ || s/a/t/ || s/t/a/;
    push(@$r_destination,$_);
    &reverse_recurse($r_source,$r_destination);
}

Bio/Tools/Alignment/Consed.pm  view on Meta::CPAN

	   consensus sequences.
 Returns : Nothing.
 Args    : None.

Acts on doublets only. Really very somewhat quite ugly. A disgusting
kludge. I<insert pride here> It was written stepwise with no real plan
because it was not really evident why consed (phrap?)  was doing this.

=cut

sub show_missing_sequence() {

    # decide which sequence should not have been clipped at consensus
    # position = 0

    my $self = shift;
    &get_phreds($self);
    my ($current_contig,@qualities);
    foreach $current_contig (sort keys %{$self->{'contigs'}}) {
	if ($self->{'contigs'}->{$current_contig}->{'class'} eq "doublet") {
	    my $number_leading_xs = 0;

Bio/Tools/OddCodes.pm  view on Meta::CPAN

 Title   : structural
 Usage   : $output = $oddcode_obj->structural();
 Function: turns amino acid sequence into 3-letter structural alphabet
	 : A (ambivalent), E (external), I (internal)
 Example : a sequence ACDEFGH will become AAEEIAE
 Returns : Reference to the new sequence string
 Args    : none

=cut

sub structural()
{
	my $self = $_[0];
	my $seqstring = &_pullseq($self);	# see _pullseq() below

# now the real business

	$seqstring =~ tr/[ACGPSTWY]/1/;
	$seqstring =~ tr/[RNDQEHK]/2/;
	$seqstring =~ tr/[ILMFV]/3/;
	$seqstring =~ tr/1/A/;

Bio/Tools/OddCodes.pm  view on Meta::CPAN

 Title   : functional
 Usage   : $output = $oddcode_obj->functional();
 Function: turns amino acid sequence into 4-letter functional alphabet
	 : A (acidic), C (basic), H (hydrophobic), P (polar)
 Example : a sequence ACDEFGH will become HPAAHHC
 Returns : Reference to the new sequence string
 Args    : none

=cut

sub functional()
{
	my $self = $_[0];
	my $seqstring = &_pullseq($self);

# now the real business

	$seqstring =~ tr/[DE]/1/;
	$seqstring =~ tr/[HKR]/2/;
	$seqstring =~ tr/[AFILMPVW]/3/;
	$seqstring =~ tr/[CGNQSTY]/4/;

Bio/Tools/OddCodes.pm  view on Meta::CPAN

 Title   : hydrophobic
 Usage   : $output = $oddcode_obj->hydrophobic();
 Function: turns amino acid sequence into 2-letter hydrophobicity alphabet
	 : O (hydrophobic), I (hydrophilic)
 Example : a sequence ACDEFGH will become OIIIOII
 Returns : Reference to the new sequence string
 Args    : none

=cut

sub hydrophobic()
{
	my $self = $_[0];
	my $seqstring = &_pullseq($self);

# now the real business

	$seqstring =~ tr/[AFILMPVW]/1/;
	$seqstring =~ tr/[CDEGHKNQRSTY]/2/;
	$seqstring =~ tr/1/I/;
	$seqstring =~ tr/2/O/;

Bio/Tools/OddCodes.pm  view on Meta::CPAN

 Usage   : $output = $oddcode_obj->Dayhoff();
 Function: turns amino acid sequence into 6-letter Dayhoff alphabet
 Example : a sequence ACDEFGH will become CADDGCE
         : A (=C),   C (=AGPST), D (=DENQ),
         : E (=HKR), F (=ILMV),  G (=FWY)
 Returns : Reference to the new sequence string
 Args    : none

=cut

sub Dayhoff()
{
	my $self = $_[0];
	my $seqstring = &_pullseq($self);

# now the real business

	$seqstring =~ tr/[C]/1/;
	$seqstring =~ tr/[AGPST]/2/;
	$seqstring =~ tr/[DENQ]/3/;
	$seqstring =~ tr/[HKR]/4/;

Bio/Tools/OddCodes.pm  view on Meta::CPAN

 Usage   : $output = $oddcode_obj->Sneath();
 Function: turns amino acid sequence into 7-letter Sneath alphabet
 Example : a sequence ACDEFGH will become CEFFHCF
         : A (=ILV), C (=AGP), D (=MNQ), E (=CST),
         : F (=DE),  G (=KR),  H (=FHWY)
 Returns : Reference to the new sequence string
 Args    : none

=cut

sub Sneath()
{
	my $self = $_[0];
	my $seqstring = &_pullseq($self);

# now the real business

	$seqstring =~ tr/[ILV]/1/;
	$seqstring =~ tr/[AGP]/2/;
	$seqstring =~ tr/[MNQ]/3/;
	$seqstring =~ tr/[CST]/4/;

Bio/Tools/OddCodes.pm  view on Meta::CPAN

 Title   : Stanfel
 Usage   : $output = $oddcode_obj->Stanfel();
 Function: turns amino acid sequence into 4-letter Stanfel alphabet
 Example : a sequence ACDEFGH will become AACCDAE
         : A (=ACGILMPSTV), C (=DENQ), D (=FWY), E (=HKR)
 Returns : Reference to the new sequence string
 Args    : none

=cut

sub Stanfel()
{
	my $self = $_[0];
	my $seqstring = &_pullseq($self);

# now the real business

	$seqstring =~ tr/[ACGILMPSTV]/1/;
	$seqstring =~ tr/[DENQ]/2/;
	$seqstring =~ tr/[FWY]/3/;
	$seqstring =~ tr/[HKR]/4/;

Bio/Tools/OddCodes.pm  view on Meta::CPAN

 Usage   : $output = $oddcode_obj->chemical();
 Function: turns amino acid sequence into 8-letter chemical alphabet
	 : A (acidic), L (aliphatic), M (amide), R (aromatic)
	 : C (basic),  H (hydroxyl),  I (imino), S (sulphur)
 Example : a sequence ACDEFGH will become LSAARAC
 Returns : Reference to the new sequence string
 Args    : none

=cut

sub chemical()
{
	my $self = $_[0];
	my $seqstring = &_pullseq($self);

# now the real business

	$seqstring =~ tr/[DE]/1/;
	$seqstring =~ tr/[AGILV]/2/;
	$seqstring =~ tr/[NQ]/3/;
	$seqstring =~ tr/[FWY]/4/;

Bio/Tools/OddCodes.pm  view on Meta::CPAN

 Title   : charge
 Usage   : $output = $oddcode_obj->charge();
 Function: turns amino acid sequence into 3-letter charge alphabet
 Example : a sequence ACDEFGH will become NNAANNC
         : A (negative; NOT anode), C (positive; NOT cathode), N (neutral)
 Returns : Reference to the new sequence string
 Args    : none

=cut

sub charge()
{
	my $self = $_[0];
	my $seqstring = &_pullseq($self);

# now the real business

	$seqstring =~ tr/[DE]/1/;
	$seqstring =~ tr/[HKR]/2/;
	$seqstring =~ tr/[ACFGILMNPQSTVWY]/3/;
	$seqstring =~ tr/1/A/;

examples/contributed/prosite2perl.pl  view on Meta::CPAN

#
# Submitted to bioperl scripts project 2001/08/03 
#
# Description: 
# Prosite patterns to Perl regular expressions.
# The prositeRegEx($) sub accepts a string
# containing a Prosite pattern and returns a
# string containing a valid Perl regex.  The code
# is self-explanatory.

sub prositeRegEx($);

while (<>) {
  chomp ($_);
  print prositeRegEx ($_), "\n";
}

sub prositeRegEx ($) {
  my $regex = shift;
  $regex =~ s/[\-\.]//g;    
  $regex =~ s/\{/[^/g; 



( run in 0.491 second using v1.01-cache-2.11-cpan-65fba6d93b7 )