<commit_before>#! /usr/bin/env python
'''Deduplicates BAM file based on custom inline DNA barcodes.
Emits a new BAM file reduced to a single consensus read for each family of
original reads.'''
##   Copyright 2014 Bioinformatics Core, University of Michigan
##
##   Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
##
##   Unless required by applicable law or agreed to in writing, software
##   distributed under the License is distributed on an "AS IS" BASIS,
##   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
##   See the License for the specific language governing permissions and
##   limitations under the License.
from __future__ import print_function, absolute_import, division
import argparse
from collections import defaultdict, Counter
from copy import deepcopy
from datetime import datetime
import itertools
import operator
import os
import sys
import traceback
import pysam
import connor.samtools

__version__ = connor.__version__

try:
    xrange
except NameError:
    xrange = range

try:
    iter_map = itertools.imap
except NameError:
    iter_map = map


DEFAULT_TAG_LENGTH = 6
DEFAULT_CONSENSUS_THRESHOLD=0.6
MIN_ORIG_READS = 3
HAMMING_THRESHOLD = 1


DESCRIPTION=\
'''Deduplicates BAM file based on custom inline DNA barcodes.
Emits a new BAM file reduced to a single consensus read for each family of
original reads.
'''

noncanonical_tag_count = 0

class _ConnorUsageError(Exception):
    """Raised for malformed command or invalid arguments."""
    def __init__(self, msg, *args):
        super(_ConnorUsageError, self).__init__(msg, *args)


class _ConnorArgumentParser(argparse.ArgumentParser):
    """Argument parser that raises UsageError instead of exiting."""
    #pylint: disable=too-few-public-methods
    def error(self, message):
        '''Suppress default exit behavior'''<commit_msg>CON-27 (cgates): Adjusted so iter map works in py2 and py3<commit_after>#! /usr/bin/env python
'''Deduplicates BAM file based on custom inline DNA barcodes.
Emits a new BAM file reduced to a single consensus read for each family of
original reads.'''
##   Copyright 2014 Bioinformatics Core, University of Michigan
##
##   Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
##
##   Unless required by applicable law or agreed to in writing, software
##   distributed under the License is distributed on an "AS IS" BASIS,
##   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
##   See the License for the specific language governing permissions and
##   limitations under the License.
from __future__ import print_function, absolute_import, division
import argparse
from collections import defaultdict, Counter
from copy import deepcopy
from datetime import datetime
import itertools
import operator
import os
import sys
import traceback
import pysam
import connor.samtools

__version__ = connor.__version__

try:
    xrange
except NameError:
    xrange = range

try:
    iter_map = itertools.imap
except AttributeError:
    iter_map = map


DEFAULT_TAG_LENGTH = 6
DEFAULT_CONSENSUS_THRESHOLD=0.6
MIN_ORIG_READS = 3
HAMMING_THRESHOLD = 1


DESCRIPTION=\
'''Deduplicates BAM file based on custom inline DNA barcodes.
Emits a new BAM file reduced to a single consensus read for each family of
original reads.
'''

noncanonical_tag_count = 0

class _ConnorUsageError(Exception):
    """Raised for malformed command or invalid arguments."""
    def __init__(self, msg, *args):
        super(_ConnorUsageError, self).__init__(msg, *args)


class _ConnorArgumentParser(argparse.ArgumentParser):
    """Argument parser that raises UsageError instead of exiting."""
    #pylint: disable=too-few-public-methods
    def error(self, message):
        '''Suppress default exit behavior'''
{'fraction_non_alphanumeric': 0.07292173067574137, 'fraction_numerical': 0.007778317938745746, 'mean_word_length': 4.4144736842105265, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1726522', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1128, 'n_words': 479}