The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

GVF::Parser - A parser for Genome Variation Format files.

VERSION

Version 0.01

SYNOPSIS

Takes a given GVF file and creates a DBIx::Class sqlite3 database. In addition to having the ability to retrive sections of pragma and feature data.

use GVF::Parser;

my $gvf = $ARGV[0] || die "Please enter gvf/db file\n";

# adding attributes to the database. # this will allow you to add desired unsupported attribute tags to the database. # they are accessed via hash tag values, # currently five extra tag are allowed. # Example: 'add_attribute1'

my $file_adds = { add_attribute1 => 'hgmd_disease', add_attribute2 => 'hgmd_location', };

my $obj = GVF::Parser->new( file => $gvf, # required file_modifier => $file_adds, # pass the unsupported tags to GVF::Parser );

# pass the request to set values. # pragmas are stored in the object # features are use to build sqlite database

$obj->pragmas; $obj->features;

#---------------------------------------------------------

# Example one # DBIx::Class approach.

# connection to db via DBIx::Class object my $dbi = $obj->get_dbixclass;

# use DBIx::Class as standard from this point. my $features = $dbi->resultset('Features'); my $attributes = $dbi->resultset('Attributes');

# create a hash of all the feature items wanted # using feature table primary key my %feats; while (my $f = $features->next) { $feats{ $f->id } = { type => $f->type, start => $f->start, end => $f->end, }; }

# use attribure resultset to access desired parts of file # using attributes foreign_key to maintain relationship with features while (my $i = $attributes->next ){ if ( $feats{ $i->features_id } ){ my $varInfo = $obj->effectHash( $i->varianteffect );

        if ( $varInfo->{'three_prime_UTR_variant'}) {
                print $varInfo->{'three_prime_UTR_variant'}->{'feature_type'}, "\t";
                print $varInfo->{'three_prime_UTR_variant'}->{'feature'}, "\t";
                print $feats{ $i->features_id }->{'start'}, "\t";
                print $feats{ $i->features_id }->{'type'}, "\t";
                print $i->referenceseq, "\t";
                print $i->variantseq, "\n";
        }
    }
}

#------------------------------------------------------------------------------

# Example two. # accessing data in parts

# Example of using request methods. my @feats = $obj->featureRequest('seqid', 'uniq'); my @atts = $obj->attributeRequest('Variant_effect'); my $regions = $obj->sequenceRegions;

# pragma can be requested with list or individually. my @wantList = qw/ multi-individual population /; my $foundList = $obj->pragmaRequest(\@list); my $foundIndv = $obj->pragmaRequest('gvf-version');

#------------------------------------------------------------------------------

SUBROUTINES/METHODS

pragmas

    Title    : pragmas
    Usage    : $obj->pragmas
    Function : Builds a SQLite3 database of Pragma values.
    Returns  : Store pragma data in obj or will return a 
               hash of pragma data.

features

    Title    : features
    Usage    : $obj->features
    Function : Builds a SQLite3 database of feature values.
    Returns  : None

getPragmas

    Title    : getPragmas
    Usage    : $obj->getPragmas($pragma)
    Function : Allow you to search for a specific pragma.
    Returns  : requested pragma

pragmaKeys

    Title    : pragmaKeys
    Usage    : $obj->pragmaKeys
    Function : Grabs a list of all pragma keys in a given file
    Returns  : pragma keys

pragmaValues

    Title    : pragmaValues
    Usage    : $obj->pragmaValues
    Function : Grabs a list of all pragma values in a given file
    Returns  : pragma values

get_dbixclass

    Title    : get_dbixclass
    Usage    : $obj->get_dbixclass
    Function : Handle, used to connect to DBIx::Class
    Returns  : DBIx::Class object

AUTHOR

Shawn Rynearson, <shawn.rynerson at gmail.com>

BUGS

Please report any bugs or feature requests to bug-gvf-parser at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=GVF-Parser. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc GVF::Parser

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2012 Shawn Rynearson.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.