<commit_before>#!/usr/bin/perl
package Format::Vcf2Maf;

use strict;
use warnings;
use File::Basename;
use CQS::PBS;
use CQS::ConfigUtils;
use CQS::SystemUtils;
use CQS::FileUtils;
use CQS::Task;
use CQS::StringUtils;

our @ISA = qw(CQS::Task);

sub new {
  my ($class) = @_;
  my $self = $class->SUPER::new();
  $self->{_name}   = __PACKAGE__;
  $self->{_suffix} = "_v2m";
  bless $self, $class;
  return $self;
}

sub perform {
  my ( $self, $config, $section ) = @_;

  my ( $task_name, $path_file, $pbs_desc, $target_dir, $log_dir, $pbs_dir, $result_dir, $option, $sh_direct, $cluster ) = get_parameter( $config, $section );

  my %raw_files = %{ get_raw_files( $config, $section ) };
  my $vcf2mgf = get_option_file($config, $section, "vcf2maf_pl");
  my $vep_path = get_option($config, $section, "vep_path");
  my $vep_data = get_option($config, $section, "vep_data");
  my $species = get_option($config, $section, "species");
  my $ncbi_build = get_option($config, $section, "ncbi_build");
  my $ref_fasta = get_option_file($config, $section, "ref_fasta");

  my $shfile = $self->get_task_filename( $pbs_dir, $task_name );
  open( my $sh, ">$shfile" ) or die "Cannot create $shfile";
  print $sh get_run_command($sh_direct) . "\n";

  for my $sample_name ( sort keys %raw_files ) {
    my @sample_files = @{ $raw_files{$sample_name} };
    my $vcf_file     = $sample_files[0];

    my $pbs_file = $self->get_pbs_filename( $pbs_dir, $sample_name );
    my $pbs_name = basename($pbs_file);
    my $log      = $self->get_log_filename( $log_dir, $sample_name );

    print $sh "\$MYCMD ./$pbs_name \n";

    my $final_file = basename($vcf_file) . ".maf";
    my $log_desc = $cluster->get_log_description($log);

    my $pbs = $self->open_pbs( $pbs_file, $pbs_desc, $log_desc, $path_file, $result_dir );

    print $pbs "
if [ ! -s $final_file ]; then
  perl $vcf2mgf --input-vcf $vcf_file --output-maf $final_file --vep-path $vep_path --vep-data $vep_data --species $species --ncbi-build $ncbi_build --ref-fasta $ref_fasta
fi
";
    $self->close_pbs( $pbs, $pbs_file );
  }
  close $sh;

  if ( is_linux() ) {
    chmod 0755, $shfile;
  }

  print "!!!shell file $shfile created, you can run this shell file to submit all Vcf2Maf tasks.\n";

  #`qsub $pbs_file`;
}

sub result {
  my ( $self, $config, $section, $pattern ) = @_;

  my ( $task_name, $path_file, $pbs_desc, $target_dir, $log_dir, $pbs_dir, $result_dir, $option, $sh_direct ) = get_parameter( $config, $section, 0 );

  my %raw_files = %{ get_raw_files( $config, $section ) };

  my $result = {};
  for my $sample_name ( keys %raw_files ) {
    my @sample_files = @{ $raw_files{$sample_name} };
    my $vcf_file     = $sample_files[0];
    my $final_file = basename($vcf_file) . ".maf";

    my @result_files = ();
    push( @result_files, $result_dir . "/" . $final_file );

    $result->{$sample_name} = filter_array( \@result_files, $pattern );<commit_msg>vcf2maf for annotation<commit_after>#!/usr/bin/perl
package Format::Vcf2Maf;

use strict;
use warnings;
use File::Basename;
use CQS::PBS;
use CQS::ConfigUtils;
use CQS::SystemUtils;
use CQS::FileUtils;
use CQS::Task;
use CQS::StringUtils;

our @ISA = qw(CQS::Task);

sub new {
  my ($class) = @_;
  my $self = $class->SUPER::new();
  $self->{_name}   = __PACKAGE__;
  $self->{_suffix} = "_v2m";
  bless $self, $class;
  return $self;
}

sub perform {
  my ( $self, $config, $section ) = @_;

  my ( $task_name, $path_file, $pbs_desc, $target_dir, $log_dir, $pbs_dir, $result_dir, $option, $sh_direct, $cluster, $thread, $memory, $init_command ) = get_parameter( $config, $section );

  my %raw_files = %{ get_raw_files( $config, $section ) };
  my $vcf2mgf = get_option_file($config, $section, "vcf2maf_pl");
  my $vep_path = get_option($config, $section, "vep_path");
  my $vep_data = get_option($config, $section, "vep_data");
  my $species = get_option($config, $section, "species");
  my $ncbi_build = get_option($config, $section, "ncbi_build");
  my $ref_fasta = get_option_file($config, $section, "ref_fasta");
  my $filter_vcf;
  if (defined $config->{$section}{filter_vcf}){
    $filter_vcf = "--filter-vcf " . get_option_file($config, $section, "filter_vcf");
  }else{
    $filter_vcf = "--filter-vcf 0"
  }

  for my $sample_name ( sort keys %raw_files ) {
    my @sample_files = @{ $raw_files{$sample_name} };
    my $vcf_file     = $sample_files[0];

    my $pbs_file = $self->get_pbs_filename( $pbs_dir, $sample_name );
    my $pbs_name = basename($pbs_file);
    my $log      = $self->get_log_filename( $log_dir, $sample_name );

    my $final_file = basename($vcf_file) . ".maf";
    my $log_desc = $cluster->get_log_description($log);

    my $pbs = $self->open_pbs( $pbs_file, $pbs_desc, $log_desc, $path_file, $result_dir );

    print $pbs "
if [ ! -s $final_file ]; then
  perl $vcf2mgf --vep-forks $thread --input-vcf $vcf_file --output-maf $final_file --vep-path $vep_path --vep-data $vep_data --species $species --ncbi-build $ncbi_build --ref-fasta $ref_fasta $filter_vcf
fi
";
    $self->close_pbs( $pbs, $pbs_file );
  }

  #`qsub $pbs_file`;
}

sub result {
  my ( $self, $config, $section, $pattern ) = @_;

  my ( $task_name, $path_file, $pbs_desc, $target_dir, $log_dir, $pbs_dir, $result_dir, $option, $sh_direct ) = get_parameter( $config, $section, 0 );

  my %raw_files = %{ get_raw_files( $config, $section ) };

  my $result = {};
  for my $sample_name ( keys %raw_files ) {
    my @sample_files = @{ $raw_files{$sample_name} };
    my $vcf_file     = $sample_files[0];
    my $final_file = basename($vcf_file) . ".maf";

    my @result_files = ();
    push( @result_files, $result_dir . "/" . $final_file );

    $result->{$sample_name} = filter_array( \@result_files, $pattern );
{'fraction_non_alphanumeric': 0.17795577224447154, 'fraction_numerical': 0.004004875500609437, 'mean_word_length': 4.156193895870736, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6573439', 'n_tokens_mistral': 2374, 'n_tokens_neox': 2282, 'n_words': 501}