<commit_before>#!/usr/bin/perl 
# 
# 
# 
# 
# <NAME> (04 Dec 2013), contact: <EMAIL>

use strict;
use warnings;
use Data::Dumper;

use lib '/software/packages/depthDB/modules';
use CTRU::depthDB;

my $dbhost = 'mgsrv01';
my $dbname = 'depths_exome_5bp';
my $dbi = CTRU::depthDB::connect($dbname, $dbhost, "easih_admin", "easih");

use Getopt::Std;

my $infile = shift || usage();
$infile =~ s/^\.\///;
$infile =~ s/\..*//;
my $cwd      = `pwd`;
chomp($cwd);



my $sample_name = $infile;
$sample_name =~ s/.*\///;
$sample_name =~ s/.bam//;
$sample_name =~ s/\_mem//;

print " $infile :: $sample_name\n";

my $sid = CTRU::depthDB::add_sample( $sample_name );

readin_stats("$infile.bam.flagstat", "$infile.bam.isize", "$infile.vcf.qc");





# 
# 
# 
# <NAME> (04 Dec 2013)
sub readin_stats {
  my ($flagstat_file, $isize_file, $vcf_qc_file) = @_;

  my %res;
  open (my $in, $flagstat_file) || die "Could not open '$flagstat_file': $!\n";
  while(<$in>) {
#    print;
    if ( /(\d+) .*total/) {
      $res{total_reads} = $1;
    }
    elsif ( /^(\d+) .*duplicates/) {
      $res{dup_reads} = $1;
    }
    elsif ( /(\d+) .*mapped \((.*?)%/) {
      $res{mapped_reads} = $1;
      $res{mapped_perc} = $2;
    }
    elsif ( /(\d+) .*properly paired/) {
      $res{properly_paired} = $1;
    }
    elsif ( /(\d+) .*singletons/) {<commit_msg>new place for the vcfQC file<commit_after>#!/usr/bin/perl 
# 
# 
# 
# 
# <NAME> (04 Dec 2013), contact: <EMAIL>

use strict;
use warnings;
use Data::Dumper;

use lib '/software/packages/depthDB/modules';
use CTRU::depthDB;

my $dbhost = 'mgsrv01';
my $dbname = 'depths_exome_5bp';
my $dbi = CTRU::depthDB::connect($dbname, $dbhost, "easih_admin", "easih");

use Getopt::Std;

my $infile = shift || usage();
$infile =~ s/^\.\///;
$infile =~ s/\..*//;
my $cwd      = `pwd`;
chomp($cwd);


my $qc_file = "$infile.vcf.qc";
if ( ! -e "$qc_file" ) {
  $qc_file =~ s/.*\///;
  if ( -e "vcfs/$qc_file" ) {
    $qc_file = "vcfs/$qc_file";
  }
  else { 
    die "Cannot find qc file (vcfs/$qc_file)!\n";
  }
}


my $sample_name = $infile;
$sample_name =~ s/.*\///;
$sample_name =~ s/.bam//;
$sample_name =~ s/\_mem//;

print " $infile :: $sample_name\n";

my $sid = CTRU::depthDB::add_sample( $sample_name );

readin_stats("$infile.bam.flagstat", "$infile.bam.isize", $qc_file);





# 
# 
# 
# <NAME> (04 Dec 2013)
sub readin_stats {
  my ($flagstat_file, $isize_file, $vcf_qc_file) = @_;

  my %res;
  open (my $in, $flagstat_file) || die "Could not open '$flagstat_file': $!\n";
  while(<$in>) {
#    print;
    if ( /(\d+) .*total/) {
      $res{total_reads} = $1;
    }
    elsif ( /^(\d+) .*duplicates/) {
      $res{dup_reads} = $1;
    }
    elsif ( /(\d+) .*mapped \((.*?)%/) {
      $res{mapped_reads} = $1;
      $res{mapped_perc} = $2;
    }
    elsif ( /(\d+) .*properly paired/) {
      $res{properly_paired} = $1;
    }
    elsif ( /(\d+) .*singletons/) {
{'fraction_non_alphanumeric': 0.23766816143497757, 'fraction_numerical': 0.013797861331493619, 'mean_word_length': 2.918918918918919, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2098990', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1292, 'n_words': 252}