Skip to content

Commit

Permalink
Reformat docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
veghp committed Jul 23, 2024
1 parent e42b33b commit 0a8a897
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions dna_mutator/Mutator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ class Mutator:
"""Class to generate simulations of structural and single nucleotide variants.
**Parameters**
Parameters
----------
**reference**
> A `SeqRecord` instance.
reference
A `SeqRecord` instance.
**library_size**
> Library size (`int`).
library_size
Library size (`int`).
"""

def __init__(self, reference, library_size=10):
Expand All @@ -28,7 +29,7 @@ def __init__(self, reference, library_size=10):
self.variant_records = []

def write_sample_sheet(self, csv_file):
"""Create a sample sheet (for use with Sequeduct)"""
"""Create a sample sheet (for use with Sequeduct)."""
barcode_dir = [
"barcode" + ("{0:02d}".format(i + 1))
for i in range(len(self.variant_records))
Expand All @@ -40,19 +41,20 @@ def write_sample_sheet(self, csv_file):

@staticmethod
def subtract_bases(seq, pos, n):
"""Substract N bases from a sequence
"""Substract N bases from a sequence.
**Parameters**
Parameters
----------
**seq**
> `Seq` instance.
seq
`Seq` instance.
**pos**
> Location of change (`int`).
pos
Location of change (`int`).
**n**
> Number of bases to subtract (`int`).
n
Number of bases to subtract (`int`).
"""
modified_sequence = MutableSeq(seq)
deleted_sequence = modified_sequence[pos : pos + n]
Expand All @@ -66,22 +68,24 @@ def subtract_bases(seq, pos, n):

@staticmethod
def get_random_pos(record, n=1):
"""Get n different random positions in a record"""
"""Get n different random positions in a record."""
positions = random.sample(range(0, len(record)), n)

return positions

@staticmethod
def read_genbank(genbank, use_file_name_as_id=True):
"""Get the reference sequence and features from input file
"""Get the reference sequence and features from input file.
**Parameters**
**genbank**
> Path to Genbank file (`str`).
Parameters
----------
**use_file_name_as_id**
> Replace record id and name with the filename (`bool`).
genbank
Path to Genbank file (`str`).
use_file_name_as_id
Replace record id and name with the filename (`bool`).
"""
record = SeqIO.read(genbank, "genbank")
if use_file_name_as_id:
Expand All @@ -92,7 +96,7 @@ def read_genbank(genbank, use_file_name_as_id=True):

@staticmethod
def write_genbank(record, file_name):
"""Write SeqRecord to a Genbank file"""
"""Write SeqRecord to a Genbank file."""
SeqIO.write(record, file_name, "gb")

def write_all_records(self, dir_name):
Expand All @@ -108,7 +112,7 @@ def write_all_records(self, dir_name):
self.write_genbank(variant, variant_path + extension)

def DelN(self, bases=1):
"""Simulate N base deletion"""
"""Simulate N base deletion."""
positions = self.get_random_pos(self.reference, n=self.library_size)
for i in range(self.library_size):
position = positions[i]
Expand Down

0 comments on commit 0a8a897

Please sign in to comment.