<commit_before>/*
    SWARM

    Copyright (C) 2012 <NAME> and <NAME>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    Contact: <NAME> <<EMAIL>>,
    Department of Informatics, University of Oslo,
    PO Box 1080 Blindern, NO-0316 Oslo, Norway
*/

#include "swarm.h"

/* ARGUMENTS AND THEIR DEFAULTS */

#define DEFAULT_GAPOPEN 12
#define DEFAULT_GAPEXTEND 4
#define DEFAULT_MATCHSCORE 5
#define DEFAULT_MISMATCHSCORE (-4)
#define DEFAULT_THREADS 1
#define DEFAULT_RESOLUTION 1

char * outfile;
char * progname;
char * databasename;
long gapopen;
long gapextend;
long matchscore;
long mismatchscore;
long threads;
long resolution;

long penalty_factor;
long penalty_gapextend;
long penalty_gapopen;
long penalty_mismatch;

/* Other variables */

long mmx_present;
long sse_present;
long sse2_present;
long sse3_present;
long ssse3_present;
long sse41_present;
long sse42_present;
long popcnt_present;
long avx_present;

unsigned long dbsequencecount = 0;

FILE * out;

char sym_nt[] = "-acgt                           ";

#define cpuid(f,a,b,c,d)						\
  __asm__ __volatile__ ("cpuid":					\
			"=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (f));

void cpu_features_detect()
{
  unsigned int a __attribute__ ((unused));
  unsigned int b __attribute__ ((unused));
  unsigned int c, d;

  cpuid(1,a,b,c,d);

  mmx_present    = (d >> 23) & 1;
  sse_present    = (d >> 25) & 1;
  sse2_present   = (d >> 26) & 1;
  sse3_present   = (c >>  0) & 1;
  ssse3_present  = (c >>  9) & 1;
  sse41_present  = (c >> 19) & 1;
  sse42_present  = (c >> 20) & 1;
  popcnt_present = (c >> 23) & 1;
  avx_present    = (c >> 28) & 1;
}

void cpu_features_show()
{
  fprintf(stderr, "CPU features:     ");
  if (mmx_present)
    fprintf(stderr, " mmx");
  if (sse_present)
    fprintf(stderr, " sse");
  if (sse2_present)
    fprintf(stderr, " sse2");
  if (sse3_present)
    fprintf(stderr, " sse3");
  if (ssse3_present)
    fprintf(stderr, " ssse3");
  if (sse41_present)
    fprintf(stderr, " sse4.1");
  if (sse42_present)
    fprintf(stderr, " sse4.2");
  if (popcnt_present)
    fprintf(stderr, " popcnt");
  if (avx_present)
    fprintf(stderr, " avx");
  fprintf(stderr, "\n");
}


void args_getstring(int i, int argc, char **argv, char ** result, char * error)
{
  if (i+1 < argc)
    *result = argv[i+1];
  else
    fatal(error);
}

void args_getnum(int i, int argc, char **argv, long * result, char * error)
{
  if (i+1 < argc)
    *result = atol(argv[i+1]);
  else
    fatal(error);
}

void args_show()
{
  cpu_features_show();
  fprintf(stderr, "Input data file:   %s\n", databasename ? databasename : "(stdin)");
  fprintf(stderr, "Input data size:   %ld residues", db_getnucleotidecount());
  fprintf(stderr, " in %ld sequences\n", db_getsequencecount());
  fprintf(stderr, "Longest sequence:  %ld residues\n", db_getlongestsequence());
  fprintf(stderr, "Output file:       %s\n", outfile ? outfile : "(stdout)");
  fprintf(stderr, "Differences:       %ld\n", resolution);
  fprintf(stderr, "Threads:           %ld\n", threads);
  fprintf(stderr, "Match score:       %ld\n", matchscore);
  fprintf(stderr, "Mismatch penalty:  %ld\n", -mismatchscore);
  fprintf(stderr, "Gap penalties:     opening: %ld, extension: %ld\n", gapopen, gapextend);
  fprintf(stderr, "Converted costs:   factor: %ld, mismatch: %ld, gap opening: %ld, gap extension: %ld\n",
	  penalty_factor, penalty_mismatch, penalty_gapopen, penalty_gapextend);
}

void args_usage()
{
  /*               0         1         1         1         1         1         1         1          */
  /*               01234567890123456789012345678901234567890123456789012345678901234567890123456789 */

  fprintf(stderr, "Usage: %s [OPTIONS] [filename]\n", progname);
  fprintf(stderr, "  -d, --differences INTEGER           resolution (1)\n");
  fprintf(stderr, "  -h, --help                          display this help and exit\n");
  fprintf(stderr, "  -o, --output-file FILENAME          output result filename (stdout)\n");
  fprintf(stderr, "  -t, --threads INTEGER               number of threads to use (1)\n");
  fprintf(stderr, "  -v, --version                       display version information and exit\n");
  fprintf(stderr, "  -m, --match-reward INTEGER          reward for nucleotide match (5)\n");
  fprintf(stderr, "  -p, --mismatch-penalty INTEGER      penalty for nucleotide mismatch (4)\n");
  fprintf(stderr, "  -g, --gap-opening-penalty INTEGER   gap open penalty (12)\n");<commit_msg>Replace the word residues with nucleotides<commit_after>/*
    SWARM

    Copyright (C) 2012 <NAME> and <NAME>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    Contact: <NAME> <<EMAIL>>,
    Department of Informatics, University of Oslo,
    PO Box 1080 Blindern, NO-0316 Oslo, Norway
*/

#include "swarm.h"

/* ARGUMENTS AND THEIR DEFAULTS */

#define DEFAULT_GAPOPEN 12
#define DEFAULT_GAPEXTEND 4
#define DEFAULT_MATCHSCORE 5
#define DEFAULT_MISMATCHSCORE (-4)
#define DEFAULT_THREADS 1
#define DEFAULT_RESOLUTION 1

char * outfile;
char * progname;
char * databasename;
long gapopen;
long gapextend;
long matchscore;
long mismatchscore;
long threads;
long resolution;

long penalty_factor;
long penalty_gapextend;
long penalty_gapopen;
long penalty_mismatch;

/* Other variables */

long mmx_present;
long sse_present;
long sse2_present;
long sse3_present;
long ssse3_present;
long sse41_present;
long sse42_present;
long popcnt_present;
long avx_present;

unsigned long dbsequencecount = 0;

FILE * out;

char sym_nt[] = "-acgt                           ";

#define cpuid(f,a,b,c,d)						\
  __asm__ __volatile__ ("cpuid":					\
			"=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (f));

void cpu_features_detect()
{
  unsigned int a __attribute__ ((unused));
  unsigned int b __attribute__ ((unused));
  unsigned int c, d;

  cpuid(1,a,b,c,d);

  mmx_present    = (d >> 23) & 1;
  sse_present    = (d >> 25) & 1;
  sse2_present   = (d >> 26) & 1;
  sse3_present   = (c >>  0) & 1;
  ssse3_present  = (c >>  9) & 1;
  sse41_present  = (c >> 19) & 1;
  sse42_present  = (c >> 20) & 1;
  popcnt_present = (c >> 23) & 1;
  avx_present    = (c >> 28) & 1;
}

void cpu_features_show()
{
  fprintf(stderr, "CPU features:     ");
  if (mmx_present)
    fprintf(stderr, " mmx");
  if (sse_present)
    fprintf(stderr, " sse");
  if (sse2_present)
    fprintf(stderr, " sse2");
  if (sse3_present)
    fprintf(stderr, " sse3");
  if (ssse3_present)
    fprintf(stderr, " ssse3");
  if (sse41_present)
    fprintf(stderr, " sse4.1");
  if (sse42_present)
    fprintf(stderr, " sse4.2");
  if (popcnt_present)
    fprintf(stderr, " popcnt");
  if (avx_present)
    fprintf(stderr, " avx");
  fprintf(stderr, "\n");
}


void args_getstring(int i, int argc, char **argv, char ** result, char * error)
{
  if (i+1 < argc)
    *result = argv[i+1];
  else
    fatal(error);
}

void args_getnum(int i, int argc, char **argv, long * result, char * error)
{
  if (i+1 < argc)
    *result = atol(argv[i+1]);
  else
    fatal(error);
}

void args_show()
{
  cpu_features_show();
  fprintf(stderr, "Input data file:   %s\n", databasename ? databasename : "(stdin)");
  fprintf(stderr, "Input data size:   %ld nucleotides", db_getnucleotidecount());
  fprintf(stderr, " in %ld sequences\n", db_getsequencecount());
  fprintf(stderr, "Longest sequence:  %ld nucleotides\n", db_getlongestsequence());
  fprintf(stderr, "Output file:       %s\n", outfile ? outfile : "(stdout)");
  fprintf(stderr, "Differences:       %ld\n", resolution);
  fprintf(stderr, "Threads:           %ld\n", threads);
  fprintf(stderr, "Match score:       %ld\n", matchscore);
  fprintf(stderr, "Mismatch penalty:  %ld\n", -mismatchscore);
  fprintf(stderr, "Gap penalties:     opening: %ld, extension: %ld\n", gapopen, gapextend);
  fprintf(stderr, "Converted costs:   factor: %ld, mismatch: %ld, gap opening: %ld, gap extension: %ld\n",
	  penalty_factor, penalty_mismatch, penalty_gapopen, penalty_gapextend);
}

void args_usage()
{
  /*               0         1         1         1         1         1         1         1          */
  /*               01234567890123456789012345678901234567890123456789012345678901234567890123456789 */

  fprintf(stderr, "Usage: %s [OPTIONS] [filename]\n", progname);
  fprintf(stderr, "  -d, --differences INTEGER           resolution (1)\n");
  fprintf(stderr, "  -h, --help                          display this help and exit\n");
  fprintf(stderr, "  -o, --output-file FILENAME          output result filename (stdout)\n");
  fprintf(stderr, "  -t, --threads INTEGER               number of threads to use (1)\n");
  fprintf(stderr, "  -v, --version                       display version information and exit\n");
  fprintf(stderr, "  -m, --match-reward INTEGER          reward for nucleotide match (5)\n");
  fprintf(stderr, "  -p, --mismatch-penalty INTEGER      penalty for nucleotide mismatch (4)\n");
  fprintf(stderr, "  -g, --gap-opening-penalty INTEGER   gap open penalty (12)\n");
{'fraction_non_alphanumeric': 0.1298675821481118, 'fraction_numerical': 0.03393820500245218, 'mean_word_length': 3.1480878763222133, 'pattern_counts': {'":': 2, '<': 19, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6969474', 'n_tokens_mistral': 3753, 'n_tokens_neox': 3501, 'n_words': 1034}