App-Dazz
view release on metacpan or search on metacpan
lib/App/Dazz/Command/cover.pm view on Meta::CPAN
$meta_of->{TRUSTED}->subtract( $meta_of->{NON_OVERLAPPED} );
$meta_of->{TRUSTED}->subtract( $meta_of->{REPEAT_LIKE} );
}
{
# paf to covered
my $cmd;
$cmd .= "ovlpr covered";
$cmd .= " $infile";
$cmd .= " --coverage $opt->{coverage}";
$cmd .= " --len $opt->{len} --idt $opt->{idt}";
$cmd .= " -o $basename.covered.txt";
App::Dazz::Common::exec_cmd( $cmd, { verbose => $opt->{verbose}, } );
if ( !$tempdir->child("$basename.covered.txt")->is_file ) {
Carp::croak "Failed: create $basename.covered.txt\n";
}
}
# anchor_id => covered region
my $covered_of = {};
$meta_of->{PARTIAL_COVERED} = AlignDB::IntSpan->new;
for my $line ( App::RL::Common::read_lines("$basename.covered.txt") ) {
my @parts = split ":", $line;
next unless @parts == 2;
my $seq_id = $parts[0];
next unless $first_range->contains($seq_id);
my $covered = AlignDB::IntSpan->new()->add_runlist( $parts[1] );
if ( $covered->size < $len_of->{$seq_id} ) {
$meta_of->{TRUSTED}->remove($seq_id);
$meta_of->{PARTIAL_COVERED}->add($seq_id);
$covered_of->{$seq_id} = $covered->runlist;
}
}
# {
# # Create covered.fasta
# $tempdir->child("covered.fasta")->remove;
# for my $serial ( sort { $a <=> $b } keys %{$covered_of} ) {
# if ( $trusted->contains($serial) ) {
# my $cmd;
# $cmd .= "DBshow -U $basename $serial";
# $cmd .= " | faops replace -l 0 stdin first.replace.tsv stdout";
# $cmd .= " >> covered.fasta";
# App::Dazz::Common::exec_cmd( $cmd, { verbose => $opt->{verbose}, } );
# }
# else {
#
# #@type AlignDB::IntSpan
# my $region = $covered_of->{$serial}{ $opt->{coverage} };
#
# for my $set ( $region->sets ) {
# next if $set->size < $opt->{len};
#
# my $cmd;
# $cmd .= "DBshow -U $basename $serial";
# $cmd .= " | faops replace -l 0 stdin first.replace.tsv stdout";
# $cmd .= " | faops frag -l 0 stdin @{[$set->min]} @{[$set->max]} stdout";
# $cmd .= " >> covered.fasta";
# App::Dazz::Common::exec_cmd( $cmd, { verbose => $opt->{verbose}, } );
# }
# }
# }
#
# if ( !$tempdir->child("covered.fasta")->is_file ) {
# Carp::croak "Failed: create covered.fasta\n";
# }
# }
{
$meta_of->{TRUSTED} = $meta_of->{TRUSTED}->runlist;
$meta_of->{NON_OVERLAPPED} = $meta_of->{NON_OVERLAPPED}->runlist;
$meta_of->{REPEAT_LIKE} = $meta_of->{REPEAT_LIKE}->runlist;
$meta_of->{PARTIAL_COVERED} = $meta_of->{PARTIAL_COVERED}->runlist;
$meta_of->{TOTAL_RANGE} = $first_range->runlist;
$tempdir->child("meta.cover.json")
->spew( JSON::to_json( $meta_of, { pretty => 1, canonical => 1, } ) );
$tempdir->child("meta.cover.json")->copy( $opt->{outfile} );
$tempdir->child("partial.txt")
->spew( map { sprintf "%s:%s\n", $_, $covered_of->{$_} } keys %{$covered_of} );
$tempdir->child("partial.txt")->copy("$opt->{outfile}.partial.txt");
YAML::Syck::DumpFile( "coverage.yml", $coverage_of );
$tempdir->child("coverage.yml")->copy("$opt->{outfile}.coverage.yml");
}
chdir $cwd;
}
1;
( run in 0.689 second using v1.01-cache-2.11-cpan-b16cb0d3907 )