Commit f9bc6c5e authored by jkvis's avatar jkvis
Browse files

Added documentation and source comments

parent 3dfd70e6
// *******************************************************************
// (C) Copyright 2014 Leiden Institute of Advanced Computer Science
// Universiteit Leiden
// All Rights Reserved
// *******************************************************************
// Extractor (library)
// *******************************************************************
// FILE INFORMATION:
// File: debug.cc
// Author: Jonathan K. Vis
// Revision: 2.01a
// Date: 2014/07/29
// *******************************************************************
// DESCRIPTION:
// This source can be used to debug the Extractor library within
// C/C++. It opens two files given as arguments and perform the
// description extraction. Supply the -D__debug__ flag in the
// Makefile for tracing.
// *******************************************************************
#include "extractor.h"
using namespace mutalyzer;
#include <cstdio>
// Entry point.
int main(int argc, char* argv[])
{
......@@ -11,8 +32,10 @@ int main(int argc, char* argv[])
fprintf(stderr, "usage: %s reference sample\n", argv[0]);
return 1;
} // if
fprintf(stderr, "HGVS description extractor\n");
// Opening files.
FILE* file = fopen(argv[1], "r");
if (file == 0)
{
......@@ -41,19 +64,23 @@ int main(int argc, char* argv[])
fclose(file);
// The actual extraction.
std::vector<Variant> variant;
size_t const weight = extract(variant, reference, reference_length, sample, sample_length);
fprintf(stderr, "\nVariants (%ld / %ld):\n", variant.size(), weight);
// Printing the variants.
fprintf(stdout, "\nVariants (%ld / %ld):\n", variant.size(), weight);
for (std::vector<Variant>::iterator it = variant.begin() ; it != variant.end(); ++it)
{
//if (it->type != IDENTITY)
{
fprintf(stderr, "%ld--%ld, %ld--%ld, %d, %ld, %ld--%ld\n", it->reference_start, it->reference_end, it->sample_start, it->sample_end, it->type, it->weight, it->transposition_start, it->transposition_end);
fprintf(stdout, "%ld--%ld, %ld--%ld, %d, %ld, %ld--%ld\n", it->reference_start, it->reference_end, it->sample_start, it->sample_end, it->type, it->weight, it->transposition_start, it->transposition_end);
} // if
} // for
// Cleaning up.
delete[] reference;
delete[] sample;
......
This diff is collapsed.
This diff is collapsed.
......@@ -9,7 +9,7 @@
// File: extractor.i (SWIG interface file)
// Author: Jonathan K. Vis
// Revision: 2.01a
// Date: 2014/07/28
// Date: 2014/07/29
// *******************************************************************
// DESCRIPTION:
// Defines the SWIG interface for the Extractor library for use in
......@@ -31,19 +31,55 @@ namespace std
namespace mutalyzer
{
static char const* const VERSION = "Description Extractor Rev 2.01a (2014/07/28)";
// Version string for run-time identification.
static char const* const VERSION = "Description Extractor Rev 2.01a (2014/07/29)";
// The character type used for all strings. For now it should be just
// a char.
typedef char char_t;
// These constants can be used to specify the type of string to be
// extracted. The extractor is primarily focussed on DNA/RNA. When
// TYPE_PROTEIN (or another value) is used no complement string is
// constructed and no reverse complement is calculated.
static int const TYPE_DNA = 0;
static int const TYPE_PROTEIN = 1;
// These constants can be used to deterimine the type of variant.
// Substitution covers most: deletions, insertions, substitutions, and
// insertion/deletions. Indentity is used to describe the unchanged
// (matched) regions. The transposition constants are coded as
// bitfields and should be appropriately combined, e.g.,
// IDENTITY | TRANSPOSITION_OPEN for describing a real transposition.
// Note that some combinations do NOT make sense, e.g.,
// SUBSTITUION | REVERSE_COMPLEMENT.
static int const IDENTITY = 0;
static int const REVERSE_COMPLEMENT = 1;
static int const SUBSTITUTION = 2;
static int const TRANSPOSITION_OPEN = 4;
static int const TRANSPOSITION_CLOSE = 8;
// *******************************************************************
// Variant structure
// This structure describes a variant (region of change).
//
// @member reference_start: starting position of the variant within
// the reference string
// @member reference_end: ending position of the variant within the
// reference string
// @member sample_start: starting position of the variant within the
// sample string
// @member sample_end: ending position of the variant within the
// sample string
// @member type: type of the variant described using the
// constants above
// @member weight: weight of the variant according to the weight
// constants above (used internally)
// @member transposition_start: starting position of a transposition
// withing the reference string
// @member transposition_end: ending position of a transposition
// withing the reference string
// *******************************************************************
struct Variant
{
size_t reference_start;
......@@ -56,6 +92,18 @@ struct Variant
size_t transposition_end;
}; // Variant
// *******************************************************************
// extract function
// This function is the interface function for Python.
//
// @arg reference: reference string
// @arg reference_length: length of the reference string
// @arg sample: sample string
// @arg sample_length: length of the sample string
// @arg type: type of strings 0 --- DNA/RNA (default)
// 1 --- Protein/other
// @return: vector of variants
// *******************************************************************
std::vector<Variant> extract(char_t const* const reference,
size_t const reference_length,
char_t const* const sample,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment