<commit_before>#!/usr/bin/env perl

use strict;
use Getopt::Long;
use Pod::Usage;
use File::Spec qw (rel2abs);
use File::Temp qw (tempfile);
use File::Path qw (make_path);
use FindBin;
use lib "$FindBin::Bin/../lib";
use System;
use Configuration;

if (@ARGV == 0) {
    pod2usage(-verbose => 1);
}

my $runline = "$0 " . join (" ", @ARGV) . "\n";

my $atrampath = "$FindBin::Bin/..";
my $help = 0;
my $inputdir = "";
my $reffile = "";
my $outdir = ".";
my $debug = 0;
my $processes = 1;
my $blastdb = "";

GetOptions ('input=s' => \$inputdir,
            'reference=s' => \$reffile,
			'output|outdir=s' => \$outdir,
			'debug|verbose' => \$debug,
			'processes=i' => \$processes,
			'database|db=s' => \$blastdb,
            'help|?' => \$help) or pod2usage(-msg => "GetOptions failed.", -exitval => 2);

if ($help) {
    pod2usage(-verbose => 1);
}

if (!(-e $inputdir)) {
    pod2usage(-msg => "Must specify a directory of fasta files.", -verbose => 1);
	exit;
}

if (!(-e $reffile)) {
    pod2usage(-msg => "Must specify a valid reference fasta file.", -verbose => 1);
	exit;
}

if ($blastdb ne "") {
	my $info = `blastdbcmd -db $blastdb -info`;
	$info =~ /Database: (.+?)\n/;
	if ($1 ne $reffile) {
		pod2usage(-msg => "$blastdb is not a database created from $reffile.", -verbose => 1);
		exit;
	}
}

set_debug ($debug);

$outdir = File::Spec->rel2abs($outdir);
make_path($outdir);

my($refname, undef, undef) = File::Basename::fileparse($reffile, qw(.fasta .fa));

Configuration::initialize();

my $log_file = File::Spec->catfile($outdir, "pipeline.log");
set_log($log_file);

printlog ("Running $runline");

my $crossfile = "$blastdb.crossref";
if ($blastdb eq "") {
	$blastdb = File::Spec->catfile($outdir, "$refname.blastdb");
	$crossfile = File::Spec->catfile($outdir, "$refname.blastdb.crossref");
	my $result = system_call (Configuration::find_bin('makeblastdb') . " -in $reffile -dbtype nucl -out $blastdb", $log_file);
	my $result = system_call (Configuration::find_bin('blastn') . " -query $reffile -db $blastdb -num_threads $processes -evalue 1e-50 -out $crossfile -outfmt '6 qseqid sseqid evalue length'", $log_file);
}

open CROSS_FH, "<", $crossfile;
my $curr_gene = "";
my $cross_matrix = {};
my @cross_keys = ();
foreach my $line (<CROSS_FH>) {
	if ($line =~ /(.+?)\t(.+?)\t(.+?)\t(.+)$/) {
		my ($qseqid, $sseqid, $evalue, $length) = ($1, $2, $3, $4);
		if ($qseqid ne $curr_gene) {
			$curr_gene = $qseqid;<commit_msg>$result isn't used, so removed it.<commit_after>#!/usr/bin/env perl

use strict;
use Getopt::Long;
use Pod::Usage;
use File::Spec qw (rel2abs);
use File::Temp qw (tempfile);
use File::Path qw (make_path);
use FindBin;
use lib "$FindBin::Bin/../lib";
use System;
use Configuration;

if (@ARGV == 0) {
    pod2usage(-verbose => 1);
}

my $runline = "$0 " . join (" ", @ARGV) . "\n";

my $atrampath = "$FindBin::Bin/..";
my $help = 0;
my $inputdir = "";
my $reffile = "";
my $outdir = ".";
my $debug = 0;
my $processes = 1;
my $blastdb = "";

GetOptions ('input=s' => \$inputdir,
            'reference=s' => \$reffile,
			'output|outdir=s' => \$outdir,
			'debug|verbose' => \$debug,
			'processes=i' => \$processes,
			'database|db=s' => \$blastdb,
            'help|?' => \$help) or pod2usage(-msg => "GetOptions failed.", -exitval => 2);

if ($help) {
    pod2usage(-verbose => 1);
}

if (!(-e $inputdir)) {
    pod2usage(-msg => "Must specify a directory of fasta files.", -verbose => 1);
	exit;
}

if (!(-e $reffile)) {
    pod2usage(-msg => "Must specify a valid reference fasta file.", -verbose => 1);
	exit;
}

if ($blastdb ne "") {
	my $info = `blastdbcmd -db $blastdb -info`;
	$info =~ /Database: (.+?)\n/;
	if ($1 ne $reffile) {
		pod2usage(-msg => "$blastdb is not a database created from $reffile.", -verbose => 1);
		exit;
	}
}

set_debug ($debug);

$outdir = File::Spec->rel2abs($outdir);
make_path($outdir);

my($refname, undef, undef) = File::Basename::fileparse($reffile, qw(.fasta .fa));

Configuration::initialize();

my $log_file = File::Spec->catfile($outdir, "pipeline.log");
set_log($log_file);

printlog ("Running $runline");

my $crossfile = "$blastdb.crossref";
if ($blastdb eq "") {
	$blastdb = File::Spec->catfile($outdir, "$refname.blastdb");
	$crossfile = File::Spec->catfile($outdir, "$refname.blastdb.crossref");
	system_call (Configuration::find_bin('makeblastdb') . " -in $reffile -dbtype nucl -out $blastdb", $log_file);
	system_call (Configuration::find_bin('blastn') . " -query $reffile -db $blastdb -num_threads $processes -evalue 1e-50 -out $crossfile -outfmt '6 qseqid sseqid evalue length'", $log_file);
}

open CROSS_FH, "<", $crossfile;
my $curr_gene = "";
my $cross_matrix = {};
my @cross_keys = ();
foreach my $line (<CROSS_FH>) {
	if ($line =~ /(.+?)\t(.+?)\t(.+?)\t(.+)$/) {
		my ($qseqid, $sseqid, $evalue, $length) = ($1, $2, $3, $4);
		if ($qseqid ne $curr_gene) {
			$curr_gene = $qseqid;
{'fraction_non_alphanumeric': 0.22249539028887522, 'fraction_numerical': 0.011473058799426348, 'mean_word_length': 4.080124869927159, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 47, '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': '101300', 'n_tokens_mistral': 2022, 'n_tokens_neox': 1896, 'n_words': 472}