package PGF::GapResolution::ParseBoundaryFile; =head1 NAME PGF::GapResolution::ParseBoundaryFile =head1 SYNOPSIS use PGF::GapResolution::ParseBoundaryFile; my $obj = PGF::GapResolution::ParseBoundaryFIle->new($boundaryFile); my $uniqueStart = $obj->getUniqueStartPosition(); my $uniqueEnd = $obj->getUniqueEndPosition(); my $repeatStart = $obj->getRepeatStartPosition(); my $repeatEnd = $obj->getRepeatEndPosition(); my $anchorStart = $obj->getAnchorStart(sidOfGap, anchorSize); my $anchorEnd = $obj->getAnchorEnd(sidOfGap, anchorSize); =head1 DESCRIPTION This module parses a boundary file generated by idContigRepeats.pl as part of the Gap Resolution sub system and contains access methods to the data. The format of the $boundaryfile mentioned above are as follows, separated by a tab: 1. 2. 3. 4. The ability to calculate the unique anchor positions is also possible given the side of the gap the contig of interest resides and the size of the anchor sequence. =head1 AUTHOR(s) Kurt M. LaButti =head1 HISTORY =over =item * Kurt M. LaButti 07/21/2009 Creation =back =cut #============================================================================# use strict; use warnings; use Carp; use Carp qw(cluck); use FindBin qw($RealBin); use lib "$FindBin::RealBin/../lib"; #============================================================================# sub new { my $class = shift; my $boundaryFile = shift; my $self = {}; bless $self, $class; $self->_parseFile($boundaryFile); return $self; } #============================================================================# sub _parseFile { my $self = shift; my $file = shift; my %boundaryInfo = (); unless (open FH, $file ) { confess "ERROR: failed to open file $file: $!"; } ; #get rid of # header line while ( my $entry = ) { chomp $entry; my @entries = split /\t/, $entry; if ( @entries < 4 ) { confess "ERROR: $file does not contain a vaild entry $#entries < 4.\n"; } my $uniqueStart = $entries[0]; my $uniqueEnd = $entries[1]; my $repeatStart = $entries[2]; my $repeatEnd = $entries[3]; $boundaryInfo{'uniqueStart'} = $uniqueStart; $boundaryInfo{'uniqueEnd'} = $uniqueEnd; $boundaryInfo{'repeatStart'} = $repeatStart; $boundaryInfo{'repeatEnd'} = $repeatEnd; last; } close FH; $self->{_boundaryInfo} = \%boundaryInfo; } #============================================================================# sub getUniqueStartPosition { my $self = shift; my $uniqueStart = exists $self->{_boundaryInfo}{'uniqueStart'} ? $self->{_boundaryInfo}{'uniqueStart'} : ''; return $uniqueStart; } #============================================================================# sub getUniqueEndPosition { my $self = shift; my $uniqueEnd = exists $self->{_boundaryInfo}{'uniqueEnd'} ? $self->{_boundaryInfo}{'uniqueEnd'} : ''; return $uniqueEnd; } #============================================================================# sub repeatStartPosition { my $self = shift; my $repeatStart = exists $self->{_boundaryInfo}{'repeatStart'} ? $self->{_boundaryInfo}{'repeatStart'} : ''; return $repeatStart; } #============================================================================# sub repeatEndPosition { my $self = shift; my $repeatEnd = exists $self->{_boundaryInfo}{'repeatEnd'} ? $self->{_boundaryInfo}{'repeatEnd'} : ''; return $repeatEnd; } #============================================================================# sub getAnchorStart { my $self = shift; my $sideOfGap = shift; my $anchorSize = shift; my $anchorStart; $anchorSize = $anchorSize -1; my $uniqueStart = exists $self->{_boundaryInfo}{'uniqueStart'} ? $self->{_boundaryInfo}{'uniqueStart'} : ''; my $uniqueEnd = exists $self->{_boundaryInfo}{'uniqueEnd'} ? $self->{_boundaryInfo}{'uniqueEnd'} : ''; if ($sideOfGap =~ /left/) { $anchorStart = $uniqueEnd-$anchorSize; } elsif ($sideOfGap =~ /right/) { $anchorStart = $uniqueStart; } return $anchorStart; } #============================================================================# sub getAnchorEnd { my $self = shift; my $sideOfGap = shift; my $anchorSize = shift; my $anchorEnd; $anchorSize = $anchorSize -1; my $uniqueStart = exists $self->{_boundaryInfo}{'uniqueStart'} ? $self->{_boundaryInfo}{'uniqueStart'} : ''; my $uniqueEnd = exists $self->{_boundaryInfo}{'uniqueEnd'} ? $self->{_boundaryInfo}{'uniqueEnd'} : ''; if ($sideOfGap =~ /left/) { $anchorEnd = $uniqueEnd; } elsif ($sideOfGap =~ /right/) { $anchorEnd = $uniqueStart+$anchorSize; } return $anchorEnd; } 1;