lib/NGS/Tools/BAMSurgeon/Germline.pm untested

filter: Statementstmt 0.0% 0 / 71 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 110 CC 4 SCAR 14.4
CC
4
Cov
0%
pick_germ_mutations
12.0
germline_simulation
6.0
check_germ
2.0
CRAP 4.2
1 package NGS::Tools::BAMSurgeon::Germline;
2  
3 use warnings;
4 use strict;
5 use Carp;
6 use Moose::Role;
7 use FindBin qw($Bin);
8 use Params::Validate qw(:all);
9 use Data::Dumper;
10 use File::Path qw(make_path);
11 use YAML qw(LoadFile);
12 use HPCI;
13 use Cwd qw(abs_path);
14  
15 has 'gpercent' => (
16 is => 'ro',
17 writer => '_set_gpercent',
18 default => 0.7
19 );
20  
21 sub check_germ {
22 my $self = shift;
23  
24 $self->log->info("check_germ\n");
25  
26 # Call check_germ in module
27 }
28  
29 sub pick_germ_mutations {
30 my $self = shift;
31  
32 $self->log->info("pick_germ_mutations\n");
33 $self->log->info("\tgermline_profile: " . $self->germline_profile . "\n");
34  
35 # to store germline mutations
36 if (! -e $self->wd . "/chrbam/germ_mutations/") {
37 make_path($self->wd . "/chrbam/germ_mutations/");
38 }
39  
40 my $stages = [];
41
42 # For every chromosome, iterate over the types and muts in the profile
43 # Call pick_germ_mutations in the module
44 foreach my $chr (@{$self->chromosomes}) {
45 foreach my $type (keys $self->germline_profile->{$chr}) {
46 foreach my $mut (keys %{$self->germline_profile->{$chr}{$type}}) {
47 if (! -e $self->wd . "/chrbam/germ_mutations/" . "pick_$chr\_$mut\_$type.txt") {
48 my $split_genome_stage = $self->HPCI_group->stage(
49 name => "bs_pick_germ_$chr\_$type\_$mut",
50 command => 'randomsites.py ' .
51 "-g " . $self->wd . "/chrFa/$chr.fa " .
52 "-n " . $self->germline_profile->{$chr}{$type}{$mut}{n} . " " .
53 "--avoidN " .
54 "--minvaf " . ($self->minvaf // 1) . " " .
55 "--maxvaf " . ($self->maxvaf // 1) . " " .
56 "'$mut' " .
57 "> " . $self->wd . "/chrbam/germ_mutations/" . "pick_$chr\_$mut\_$type.txt",
58 resources_required => {
59 h_vmem => '1G'
60 },
61 modules_to_load => ['Python-BL', 'bamsurgeon/0.1.0-local']
62 );
63 push(@{$stages}, $split_genome_stage);
64 }
65 }
66 }
67 }
68 return $stages;
69 }
70  
71 sub germline_simulation {
72 my $self = shift;
73  
74 $self->log->info("germline_simulation\n");
75 $self->log->info("\tbam: " . $self->bam . "\n");
76 $self->log->info("\treference: " . $self->config->{reference} . "\n");
77 $self->log->info("\tgpercent: " . $self->gpercent . "\n");
78 $self->log->info("\tsex: " . $self->sex . "\n");
79 $self->log->info("\tphasing: " . $self->phasing . "\n");
80  
81 my $stages = [];
82  
83 foreach my $chr (@{$self->chromosomes}) {
84 my $diploid = 1;
85 if ($self->sex eq 'M' && ($chr eq 'X' || $chr eq 'Y')) {
86 $diploid = 0;
87 }
88 my $germline_stage = $self->HPCI_group->stage(
89 name => 'bs_germline_sim_' . $chr,
90 command => "perl " . $self->bin . "/germline.pl " . $self->wd . "/chrbam/ $chr $diploid " . $self->config->{reference} . " " . $self->gpercent . " " . $self->phasing,
91  
92 resources_required => {
93 h_vmem => '20G'
94 },
95 modules_to_load => [ 'Perl-BL', 'Schedule-DRMAAc' ]
96 );
97 push(@{$stages}, $germline_stage);
98 }
99  
100 return $stages;
101 }
102  
103 1;