#######################################################################
# This software has been created by Genome Research Limited (GRL).    # 
# GRL hereby grants permission to use, copy, modify and distribute    # 
# this software and its documentation for non-commercial purposes     # 
# without fee at the user's own risk on the basis set out below.      #
# GRL neither undertakes nor accepts any duty whether contractual or  # 
# otherwise in connection with the software, its use or the use of    # 
# any derivative, and makes no representations or warranties, express #
# or implied, concerning the software, its suitability, fitness for   #
# a particular purpose or non-infringement.                           #
# In no event shall the authors of the software or GRL be responsible # 
# or liable for any loss or damage whatsoever arising in any way      # 
# directly or indirectly out of the use of this software or its       # 
# derivatives, even if advised of the possibility of such damage.     #
# Our software can be freely distributed under the conditions set out # 
# above, and must contain this copyright notice.                      #
#######################################################################

package Crow_ContigFilt;

push(@INC,"$ENV{BADGER}/bin");
push(@INC,$ENV{'BIOTKPERL_LIBRARY'});
unshift(@INC,split(/:/,"$ENV{'INC_PATH'}"));

require ByTempl;


my @CurrContigs;  # current contigs
my @AllContigs;

###############################################################################################################
sub SetContigs{
    my (@conts) = @_;
    @AllContigs = @conts;
}
###############################################################################################################
sub GetContigs{
    &AllContigs;
    @CurrContigs;
}
###############################################################################################################
sub AllContigs{

    @CurrContigs = @AllContigs;
}

sub ContGT1Kb{
    my %CLR = &ByTempl::Get_CLR;
    foreach (keys(%CLR))
    {
	push(@CurrContigs,$_) if(($CLR{$_}->[1] - $CLR{$_}->[0]) > 1000);  
    }
    @CurrContigs;
}
###############################################################################################################
sub ContGT10Kb{
    my %CLR = &ByTempl::Get_CLR;
    foreach (keys(%CLR))
    {
	push(@CurrContigs,$_) if(($CLR{$_}->[1] - $CLR{$_}->[0]) > 10000);  
    }
    @CurrContigs;

}
sub ContGoodFRLinks{

    my @Data = &ByTempl::Get_Assem;
    my @gData = grep((($_->[5] == 1)&&($_->[8] == 0)&&($_->[6] == 1) && ($_->[7] ==1)),@Data);

    foreach (@gData)
    {
	push(@CurrContigs,$_->[13],$_->[14]);
    }
    @CurrContigs;
}
sub ContGoodBadFRLinks{

    my @Data = &ByTempl::Get_Assem;
    my @gData = grep(($_->[5] == 1),@Data);
    foreach (@gData)
    {
	push(@CurrContigs,$_->[13],$_->[14]);
    }
    @CurrContigs;
}
sub ContDodgyReads{

    my @Data = &ByTempl::Get_Assem;
    my @gData = grep(($_->[8] == 1),@Data);

    foreach (@gData)
    {
	push(@CurrContigs,$_->[13],$_->[14]);
    }
    @CurrContigs;
}
###############################################################################################################
1;
