Skip to content

Commit

Permalink
use copy.copy instead of list.copy
Browse files Browse the repository at this point in the history
  • Loading branch information
iskandr committed Jul 3, 2016
1 parent 7a81cb3 commit 549d4fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion isovar/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

from collections import defaultdict
import logging
# I'd rather just use list.copy but Python 2.7 doesn't support it
from copy import copy

from .read_helpers import group_unique_sequences
from .variant_sequences import VariantSequence
Expand Down Expand Up @@ -172,7 +174,7 @@ def iterative_assembly(
shorter sequences onto every longer sequence which contains them.
"""
for i in range(n_merge_iters):
previous_sequences = variant_sequences.copy()
previous_sequences = copy(variant_sequences)
variant_sequences = greedy_merge(
variant_sequences,
min_overlap_size=min_overlap_size)
Expand Down
11 changes: 9 additions & 2 deletions isovar/dataframe_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def __init__(
exclude=set([]),
converters={},
rename_dict={},
variant_columns=True):
variant_columns=True,
convert_collections_to_size=True):
"""
Parameters
----------
Expand All @@ -56,11 +57,17 @@ def __init__(
variant_columns : bool
If True, then add four columns for fields of a Variant: chr/pos/ref/alt
convert_collections_to_size : bool
If a value is a built-in collection (list, tuple, or set) then
transform it to the size of that collection. If this option is False
then collection values cause a runtime error.
"""
self.element_class = element_class
self.rename_dict = rename_dict
self.converters = converters
self.variant_columns = variant_columns
self.convert_collections_to_size = convert_collections_to_size

# remove specified field names without changing the order of the others
self.original_field_names = [
Expand Down Expand Up @@ -114,7 +121,7 @@ def add(self, variant, element):
fn = self.converters[name]
value = fn(value)

if isinstance(value, (tuple, list, set)):
if isinstance(value, (tuple, list, set)) and self.convert_collections_to_size:
value = len(value)
elif not isinstance(value, VALID_ELEMENT_TYPES):
raise ValueError(
Expand Down

0 comments on commit 549d4fd

Please sign in to comment.