<commit_before>/*
 * The contents of this file are subject to the MonetDB Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.monetdb.org/Legal/MonetDBLicense
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * The Original Code is the MonetDB Database System.
 *
 * The Initial Developer of the Original Code is CWI.
 * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
 * Copyright August 2008-2014 MonetDB B.V.
 * All Rights Reserved.
 */

/*
 * (author) <NAME>
 */

#include "monetdb_config.h"
#include "mal_exception.h"
#include "stream.h"
#include "bam_globals.h"

#include <samtools/sam.h>
#ifdef HAVE_SAMTOOLS_KSTRING_H
#include <samtools/kstring.h>
#else
/* Ubuntu doesn't distribute samtools/kstring.h, so we need our own
 * version */
#include "mykstring.h"
#endif
#include "bam_wrapper.h"

str
ordering_str(ordering ord)
{
	switch (ord) {
	case ORDERING_UNSORTED:
		return "unsorted";
	case ORDERING_QUERYNAME:
		return "queryname";
	case ORDERING_COORDINATE:
		return "coordinate";
	default:
		return "unknown";
	}
}

static ordering
get_ordering(str ord)
{
	if (strcmp(ord, "unsorted") == 0)
		return ORDERING_UNSORTED;
	if (strcmp(ord, "queryname") == 0)
		return ORDERING_QUERYNAME;
	if (strcmp(ord, "coordinate") == 0)
		return ORDERING_COORDINATE;
	return ORDERING_UNKNOWN;
}


#define ERR_INIT_BAM_WRAPPER "Could not initialize wrapper for BAM file '%s': "
/**
 * Takes a bam_wrapper and initializes it. Note that in order for the
 * accompanying clear function to work, the bam_wrapper should be
 * initialized to zero before the fields are filled in by the init
 * function.
 *
 * Binaries will be opened in dbfarm/bam, since that is the current
 * working directory.
 */
str
init_bam_wrapper(bam_wrapper * bw, filetype type, str file_location, 
         lng file_id, sht dbschema)
{
	unsigned int i;
	char flushdir[128];
<commit_msg>init_bam_wrapper(): no need to use type unsigned int rather than int<commit_after>/*
 * The contents of this file are subject to the MonetDB Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.monetdb.org/Legal/MonetDBLicense
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * The Original Code is the MonetDB Database System.
 *
 * The Initial Developer of the Original Code is CWI.
 * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
 * Copyright August 2008-2014 MonetDB B.V.
 * All Rights Reserved.
 */

/*
 * (author) <NAME>
 */

#include "monetdb_config.h"
#include "mal_exception.h"
#include "stream.h"
#include "bam_globals.h"

#include <samtools/sam.h>
#ifdef HAVE_SAMTOOLS_KSTRING_H
#include <samtools/kstring.h>
#else
/* Ubuntu doesn't distribute samtools/kstring.h, so we need our own
 * version */
#include "mykstring.h"
#endif
#include "bam_wrapper.h"

str
ordering_str(ordering ord)
{
	switch (ord) {
	case ORDERING_UNSORTED:
		return "unsorted";
	case ORDERING_QUERYNAME:
		return "queryname";
	case ORDERING_COORDINATE:
		return "coordinate";
	default:
		return "unknown";
	}
}

static ordering
get_ordering(str ord)
{
	if (strcmp(ord, "unsorted") == 0)
		return ORDERING_UNSORTED;
	if (strcmp(ord, "queryname") == 0)
		return ORDERING_QUERYNAME;
	if (strcmp(ord, "coordinate") == 0)
		return ORDERING_COORDINATE;
	return ORDERING_UNKNOWN;
}


#define ERR_INIT_BAM_WRAPPER "Could not initialize wrapper for BAM file '%s': "
/**
 * Takes a bam_wrapper and initializes it. Note that in order for the
 * accompanying clear function to work, the bam_wrapper should be
 * initialized to zero before the fields are filled in by the init
 * function.
 *
 * Binaries will be opened in dbfarm/bam, since that is the current
 * working directory.
 */
str
init_bam_wrapper(bam_wrapper * bw, filetype type, str file_location, 
         lng file_id, sht dbschema)
{
	int i;
	char flushdir[128];

{'fraction_non_alphanumeric': 0.09332425068119891, 'fraction_numerical': 0.010899182561307902, 'mean_word_length': 4.244047619047619, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7043010', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1427, 'n_words': 525}