Pileup.pm 4.44 KB
Newer Older
1 2 3 4
=pod

=head1 LICENSE

5
Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Thomas Maurel's avatar
Thomas Maurel committed
6
Copyright [2016-2018] EMBL-European Bioinformatics Institute
7

8 9 10
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
11

12 13 14 15 16 17 18
     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
19 20 21 22 23 24 25

=head1 NAME

Bio::EnsEMBL::IO::Parser::Pileup - A line-based parser for pileup (variant) format 

=cut

26 27 28
### IMPORTANT - this is a work-in-progress and needs extending to fully parse
### the content (possibly using VEP code)

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
package Bio::EnsEMBL::IO::Parser::Pileup;

use strict;
use warnings;

use base qw/Bio::EnsEMBL::IO::ColumnBasedParser/;

=head2 open

    Constructor
    Argument [1] : Filepath
    Argument [2+]: Hash of parameters for configuration, e.g. buffer sizes or 
                   specific functions for handling headers or data
    Returntype   : Bio::EnsEMBL::IO::TrackBasedParser

=cut

sub open {
    my ($caller, $filename, @other_args) = @_;
    my $class = ref($caller) || $caller;
    my $self;

    $self = $class->SUPER::open($filename, '\t|\s+', @other_args);

    if ($filename) {
      # pre-load peek buffer
      $self->next_block();
    }

    return $self;
}

## This format has no metadata

Tiago Grego's avatar
Tiago Grego committed
63
sub is_metadata { return; }
64

Tiago Grego's avatar
Tiago Grego committed
65
sub read_metadata { return; }
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238

=head2 set_fields

    Description: Setter for list of fields used in this format - uses the
                  "public" (i.e. non-raw) names of getter methods
    Returntype : Void

=cut

sub set_fields {
  my $self = shift;
  $self->{'fields'} = [qw(seqname start ref_base read_number read_bases base_qualities)];
}


=head2 get_raw_seqname

    Description: Getter for seqname field
    Returntype : String 

=cut

sub get_raw_seqname {
  my $self = shift;
  return $self->{'record'}[0];
}

=head2 get_seqname

    Description: Getter - wrapper around raw method 
                  (uses standard method name, not format-specific)
    Returntype : String 

=cut

sub get_seqname {
  my $self = shift;
  return $self->get_raw_chromosome();
}

=head2 get_raw_start

    Description: Getter for start field
    Returntype : Integer 

=cut

sub get_raw_start {
  my $self = shift;
  return $self->{'record'}[1];
}

=head2 get_start

    Description: Getter - wrapper around raw_start method
    Returntype : Integer 

=cut

sub get_start {
  my $self = shift;
  return $self->get_raw_start();
}

=head2 get_end

    Description: Getter - pileup is single coordinate so we just use start 
    Returntype : Integer

=cut

sub get_end {
  my $self = shift;
  return $self->get_raw_start();
}

=head2 get_raw_ref_base

    Description: Getter for ref_base (reference base) field
    Returntype : String 

=cut

sub get_raw_ref_base {
  my $self = shift;
  return $self->{'record'}[2];
}

=head2 get_ref_base

    Description: Getter - wrapper around get_raw_ref_base
    Returntype : String

=cut

sub get_ref_base {
  my $self = shift;
  return $self->get_raw_ref_base();
}

=head2 get_raw_read_number

    Description: Getter for read number field
    Returntype : Integer

=cut

sub get_raw_read_number {
  my $self = shift;
  return $self->{'record'}[3];
}

=head2 get_read_number

    Description: Getter - wrapper around get_raw_read_number
    Returntype : Integer

=cut

sub get_read_number {
  my $self = shift;
  return $self->get_raw_read_number;
}

=head2 get_raw_read_bases

    Description: Getter for read_bases field 
    Returntype : String

=cut

sub get_raw_read_bases {
  my $self = shift;
  return $self->{'record'}[4];
}

=head2 get_read_bases

    Description: Getter - wrapper around get_raw_read_bases
    Returntype : String

=cut

sub get_read_bases {
  my $self = shift;
  return $self->get_raw_read_bases();
}

=head2 get_raw_base_qualities

    Description: Getter for base_qualities field 
    Returntype : String

=cut

sub get_raw_base_qualities {
  my $self = shift;
  return $self->{'record'}[5];
}

=head2 get_base_qualities

    Description: Getter - wrapper around get_raw_base_qualities
    Returntype : String

=cut

sub get_base_qualities {
  my $self = shift;
  return $self->get_raw_base_qualities();
}

1;