package PGF::GapResolution::ParseScaffInfo; =head1 NAME PGF::GapResolution::ParseScaffInfo =head1 SYNOPSIS use PGF::GapResolution::ParseScaffInfo; my $obj = PGF::GapResolution::ParseScaffInfo->new($scaffInfoFile); my $gapName = $obj->getGapName(); my $gapSize = $obj->getGapSize(); my $leftContig = $obj->getLeftContig(); my $leftContigLength = $obj->getLeftContigLength(); my $rightContig = $obj->getRightContig(); my $rightContigLength = $obj->getRightContigLength(); my $scaffoldName = $obj->getScaffoldName(); =head1 DESCRIPTION This module parses the scaffinfo.txt file generated by createSubProject.pl as part of the Gap Resolution sub system and contains access methods to the data. The format of the $scaffInfoFile mentioned above are as follows, separated by a tab: 1. 2. 3. 4. 5. 6. 7. =head1 AUTHOR(s) Stephan Trong =head1 HISTORY =over =item * Stephan Trong 12/09/2008 Creation =back =cut #============================================================================# use strict; use Carp; use Carp qw(cluck); use FindBin qw($RealBin); use lib "$FindBin::RealBin/../lib"; use PGF::Utilities::Properties; my $_DEBUG = 0; my $_configFile = defined $ENV{GAPRES_CONFIG} ? $ENV{GAPRES_CONFIG} : "$RealBin/../config/gapRes.config"; my $_OBJ_PROPS = PGF::Utilities::Properties->new(-configFile=>$_configFile); $_OBJ_PROPS->setExceptionIfEntryNotFound(1); # confess if entry in config file # is not found. #============================================================================# sub new { my $class = shift; my $scaffInfoFile = shift; if ( !-s $scaffInfoFile ) { confess "ERROR: file $scaffInfoFile does not exists or is zero size.\n"; } my @fileEntries = _parseFile($scaffInfoFile); my $self = { _entries=>\@fileEntries }; bless $self, $class; return $self; } #============================================================================# sub _parseFile { my $file = shift; unless (open FH, $file ) { confess "ERROR: failed to open file $file: $!"; } chomp( my $entry = ); close FH; my @entries = split /\t/, $entry; if ( @entries < 7 ) { confess "ERROR: $file does not contain a vaild entry.\n"; } return @entries; } #============================================================================# sub getGapName { my $self = shift; return $self->{_entries}[0]; } #============================================================================# sub getGapSize { my $self = shift; return $self->{_entries}[1]; } #============================================================================# sub getLeftContigLength { my $self = shift; return $self->{_entries}[2]; } #============================================================================# sub getLeftContig { my $self = shift; return $self->{_entries}[3]; } #============================================================================# sub getRightContigLength { my $self = shift; return $self->{_entries}[4]; } #============================================================================# sub getRightContig { my $self = shift; return $self->{_entries}[5]; } #============================================================================# sub getScaffoldName { my $self = shift; return $self->{_entries}[6]; } #============================================================================# 1;