<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

__author__ = "<NAME> <<EMAIL>>"
__date__ = "19/05/2015"
__version__ = "$Revision: 2.5"

from optparse import OptionParser
from operator import itemgetter
from collections import Counter, deque
from itertools import chain
import sys, time
import random
import gc
import copy
import json, csv
import cPickle as pickle
import shelve
import math
import resource

""" global variables """
# LSH
leftPartRatio = 0.5
rightPartRatio = 0.5
printMinhashProcess = 500000

# Sequence Alignment
M1 = 1
M2 = 2
secondSample = 0
overlap = 8 # Overlap region in both directions i.e. 20 overlap in total if 10
maxAlignments = 1 # per read
requiredOverlaps = 4
maxCandMates = 5000
MUTFIND = 1


# Test variables
c1 = 0
c2 = 0
c3 = 0
c4 = 0
c5 = 0
c6 = 0
c7 = 0
c8 = 0
numreadL = 0
numreadR = 0

old = False

# ************************************************************************** #
#																			 #
#									Helpers									 #
#																			 #
# ************************************************************************** #
def optionParse():
	"""
	Parse arguments from command line.
	"""
	desc = """Compare sets of sequencing data to find mutations."""

	parser = OptionParser(usage="usage: %prog --fasta_file filename",
						  description=desc,
						  version="%prog version 2.0")

	parser.add_option("-f", "--fasta_file",
					  metavar="<FILENAME>",
					  default="../Data/Fasta/reads.fa",
					  action="store",
					  dest="fasta_file",
					  help="set <FILENAME> as fasta file.")

	parser.add_option("-n", "--normal",
					  metavar="<FILENAME>",
					  action="store",
					  dest="normal_file",
					  help="set <FILENAME> as normal reads sample.")

	parser.add_option("-d", "--diseased",
					  metavar="<FILENAME>",
					  action="store",
					  dest="diseased_file",
					  help="set <FILENAME> as diseased reads sample.")

	parser.add_option("-i", "--candidate_pairs",
					  metavar="<FILENAME>",
					  type=str,
					  action="store",
					  dest="input",
					  help="set <FILENAME> as input file containing \
							candidate pairs to import.")

	parser.add_option("-e", "--export_candidate_pairs",
					  metavar="<FILENAME>",
					  type=str,
					  action="store",
					  dest="output",
					  help="set <FILENAME> as output file to export \
							candidate pairs to. Dump as either txt, json, \
							pickle or csv file. Just put the right extension\
							and everything else is automated.")

	parser.add_option("-l", "--log_file",
					  metavar="<FILENAME>",
					  type=str,
					  default="log.txt",
					  action="store",
					  dest="log",
					  help="set <FILENAME> as log file.")

	parser.add_option("-k", "--k_size",
					  metavar="<VALUE>",
					  type=int,
					  default=12,
					  action="store",
					  dest="k",
					  help="set <VALUE> as size for k-shingles.")

	parser.add_option("-t", "--threshold",
					  metavar="<VALUE>",
					  type=float,
					  default=float(2)/3,
					  action="store",
					  dest="threshold",
					  help="set <VALUE> as threshold similarity.")

	parser.add_option("-b", "--bands",
					  metavar="<Value>",
					  type=int,
					  default=25,
					  action="store",
					  dest="bands",
					  help="set <VALUE> as the number of bands for LSH.")

	parser.add_option("-r", "--rows",
					  metavar="<Value>",
					  type=int,
					  default=40,
					  action="store",
					  dest="rows",
					  help="set <VALUE> as the number of rows for LSH.")

	parser.add_option("-x", "--similarity_measure",
					  metavar="<VALUE>",
					  type=str,
					  default="naive",
					  action="store",
					  dest="sim",
					  help="set <VALUE> as similairy measure to use.")

	parser.add_option("-m", "--minhash_alg",
					  metavar="<VALUE>",
					  type=int,
					  default="6",
					  action="store",
					  dest="m",
					  help="<VALUE> defines the minhash algorithm to use.")

	parser.add_option("-s", "--seed",
					  metavar="<VALUE>",
					  type=int,
					  default=42,
					  action="store",
					  dest="s",
					  help="set <VALUE> as seed for hash functions.")

	parser.add_option("-T", "--test",
					  metavar="<VALUE>",
					  type=int,
					  action="store",
					  dest="T",
					  help="perform test <VALUE>.")

	parser.add_option("-o", "--required_reads_overlapping",
					  metavar="<VALUE>",
					  type=int,
					  default=3,
					  action="store",
					  dest="o",
					  help="perform test <VALUE>.")

	(options, args) = parser.parse_args()

	global requiredOverlaps
	requiredOverlaps = options.o

	return options.fasta_file, options.normal_file, options.diseased_file,\
		   options.k, options.threshold, options.bands, options.rows,\
		   options.m, options.s, options.log, options.input, options.output,\
		   options.T


def memory_usage_resource():<commit_msg>Added m1 and m2 parser options<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

__author__ = "<NAME> <<EMAIL>>"
__date__ = "19/05/2015"
__version__ = "$Revision: 2.5"

from optparse import OptionParser
from operator import itemgetter
from collections import Counter, deque
from itertools import chain
import sys, time
import random
import gc
import copy
import json, csv
import cPickle as pickle
import shelve
import math
import resource

""" global variables """
# LSH
leftPartRatio = 0.5
rightPartRatio = 0.5
printMinhashProcess = 500000

# Sequence Alignment
M1 = 1
M2 = 2
secondSample = 0
overlap = 8 # Overlap region in both directions i.e. 20 overlap in total if 10
maxAlignments = 1 # per read
requiredOverlaps = 4
maxCandMates = 5000
MUTFIND = 1


# Test variables
c1 = 0
c2 = 0
c3 = 0
c4 = 0
c5 = 0
c6 = 0
c7 = 0
c8 = 0
numreadL = 0
numreadR = 0

old = False

# ************************************************************************** #
#																			 #
#									Helpers									 #
#																			 #
# ************************************************************************** #
def optionParse():
	"""
	Parse arguments from command line.
	"""
	desc = """Compare sets of sequencing data to find mutations."""

	parser = OptionParser(usage="usage: %prog --fasta_file filename",
						  description=desc,
						  version="%prog version 2.0")

	parser.add_option("-f", "--fasta_file",
					  metavar="<FILENAME>",
					  default="../Data/Fasta/reads.fa",
					  action="store",
					  dest="fasta_file",
					  help="set <FILENAME> as fasta file.")

	parser.add_option("-n", "--normal",
					  metavar="<FILENAME>",
					  action="store",
					  dest="normal_file",
					  help="set <FILENAME> as normal reads sample.")

	parser.add_option("-d", "--diseased",
					  metavar="<FILENAME>",
					  action="store",
					  dest="diseased_file",
					  help="set <FILENAME> as diseased reads sample.")

	parser.add_option("-i", "--candidate_pairs",
					  metavar="<FILENAME>",
					  type=str,
					  action="store",
					  dest="input",
					  help="set <FILENAME> as input file containing \
							candidate pairs to import.")

	parser.add_option("-e", "--export_candidate_pairs",
					  metavar="<FILENAME>",
					  type=str,
					  action="store",
					  dest="output",
					  help="set <FILENAME> as output file to export \
							candidate pairs to. Dump as either txt, json, \
							pickle or csv file. Just put the right extension\
							and everything else is automated.")

	parser.add_option("-l", "--log_file",
					  metavar="<FILENAME>",
					  type=str,
					  default="log.txt",
					  action="store",
					  dest="log",
					  help="set <FILENAME> as log file.")

	parser.add_option("-k", "--k_size",
					  metavar="<VALUE>",
					  type=int,
					  default=12,
					  action="store",
					  dest="k",
					  help="set <VALUE> as size for k-shingles.")

	parser.add_option("-t", "--threshold",
					  metavar="<VALUE>",
					  type=float,
					  default=float(2)/3,
					  action="store",
					  dest="threshold",
					  help="set <VALUE> as threshold similarity.")

	parser.add_option("-b", "--bands",
					  metavar="<Value>",
					  type=int,
					  default=25,
					  action="store",
					  dest="bands",
					  help="set <VALUE> as the number of bands for LSH.")

	parser.add_option("-r", "--rows",
					  metavar="<Value>",
					  type=int,
					  default=40,
					  action="store",
					  dest="rows",
					  help="set <VALUE> as the number of rows for LSH.")

	parser.add_option("-x", "--similarity_measure",
					  metavar="<VALUE>",
					  type=str,
					  default="naive",
					  action="store",
					  dest="sim",
					  help="set <VALUE> as similairy measure to use.")

	parser.add_option("-m", "--minhash_alg",
					  metavar="<VALUE>",
					  type=int,
					  default="6",
					  action="store",
					  dest="m",
					  help="<VALUE> defines the minhash algorithm to use.")

	parser.add_option("-s", "--seed",
					  metavar="<VALUE>",
					  type=int,
					  default=42,
					  action="store",
					  dest="s",
					  help="set <VALUE> as seed for hash functions.")

	parser.add_option("-T", "--test",
					  metavar="<VALUE>",
					  type=int,
					  action="store",
					  dest="T",
					  help="perform test <VALUE>.")

	parser.add_option("-S", "--supporting_reads",
					  metavar="<VALUE>",
					  type=int,
					  default=3,
					  action="store",
					  dest="S",
					  help="Reads required to support mutation.")
	
	parser.add_option("-o", "--mismatch_overlap",
					  metavar="<VALUE>",
					  type=int,
					  default=3,
					  action="store",
					  dest="o",
					  help="Number of allowed mismatches in overlap.")
	
	parser.add_option("-g", "--mismatch_group",
					  metavar="<VALUE>",
					  type=int,
					  default=3,
					  action="store",
					  dest="g",
					  help="Number of allowed mismatches in group.")
					  
	

	(options, args) = parser.parse_args()

	global requiredOverlaps
	requiredOverlaps = options.S
	global M1
	M1 = options.o
	global M2
	M2 = options.g

	return options.fasta_file, options.normal_file, options.diseased_file,\
		   options.k, options.threshold, options.bands, options.rows,\
		   options.m, options.s, options.log, options.input, options.output,\
		   options.T


def memory_usage_resource():
{'fraction_non_alphanumeric': 0.17722019164279365, 'fraction_numerical': 0.014620171885804603, 'mean_word_length': 2.6601590744757773, 'pattern_counts': {'":': 0, '<': 70, '<?xml version=': 0, '>': 70, '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': '178491', 'n_tokens_mistral': 4371, 'n_tokens_neox': 3135, 'n_words': 798}