[Bio] / FigKernelScripts / filter_trunc_and_fs.pl Repository:
ViewVC logotype

View of /FigKernelScripts/filter_trunc_and_fs.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Mon Nov 8 17:16:22 2010 UTC (9 years ago) by olson
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, mgrast_dev_05262011, mgrast_dev_04082011, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2011_0119, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, mgrast_dev_10262011, HEAD
Changes since 1.1: +30 -6 lines
Add SeedUtils::map_to_families for iterating over families.2c files.

Make filter_trunc_and_fs use that function, and have it delete singleton families.

#!/usr/bin/env perl

use strict;
use warnings;

use FIG;
use FIG_Config;
use Data::Dumper;
use SeedUtils;

my %special;

SeedUtils::map_to_families(\*STDIN, \&process_fam);

sub process_fam
{
    my($fam, $members) = @_;

    my @filtered_members;
    for my $peg (@$members)
    {
	if (keep($peg))
	{
	    push(@filtered_members, $peg);
	}
	else
	{
	    print STDERR "DELPEG\t$fam\t$peg\n";
	}
    }

    if (@filtered_members < 2)
    {
	print STDERR "DELFAM\t$fam\n";
    }
    else
    {
	print STDOUT "$fam\t$_\n" for @filtered_members;
    }
}
    


sub keep {
    my (@fids) = @_;
    
    my $is_good = 1;
    foreach my $fid (@fids) {
	my $genome = &FIG::genome_of($fid);
	if (not exists($special{$genome})) {
	    $special{$genome} = {};
	    if ((-d qq($FIG_Config::organisms/$genome)) &&
		(-s qq($FIG_Config::organisms/$genome/special_pegs))
		) {
		map { chomp;
		      m/^(\S+)\t(.*)/ ? ($special{$genome}->{$1}->{$2} = 1) : ()
		      } &FIG::file_read(qq($FIG_Config::organisms/$genome/special_pegs));
	    }
	}
	
	if (exists($special{$genome}->{$fid}->{possible_frameshift}) ||
	    exists($special{$genome}->{$fid}->{possibly_truncated})) {
	    $is_good = 0;
	}
    }
    
    return $is_good;
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3