Refactor regex parenthesis removal into a function
This commit is contained in:
parent
fa23b1a950
commit
7ed975c7ce
|
@ -6,6 +6,9 @@ from re import sub
|
||||||
from pandas import DataFrame, read_html, Series
|
from pandas import DataFrame, read_html, Series
|
||||||
|
|
||||||
|
|
||||||
|
def remove_parenthesis(identifier):
|
||||||
|
sequence_str = "".join(map(str, identifier))
|
||||||
|
return sub(r"[()]", "", sequence_str)
|
||||||
|
|
||||||
|
|
||||||
def extract_adapters(files) -> Tuple[Series, List]:
|
def extract_adapters(files) -> Tuple[Series, List]:
|
||||||
|
@ -33,8 +36,7 @@ def preprocess_dataframe(adapters) -> Series:
|
||||||
def save_to_file(filename, adapters) -> None:
|
def save_to_file(filename, adapters) -> None:
|
||||||
with open(filename, "w") as f:
|
with open(filename, "w") as f:
|
||||||
for index, value in adapters.iteritems():
|
for index, value in adapters.iteritems():
|
||||||
sequence_str = "".join(map(str, index))
|
sequence_id = remove_parenthesis(index)
|
||||||
sequence_id = sub(r"[()]", "", sequence_str)
|
|
||||||
fasta_entry = f">{sequence_id}\n{value}\n"
|
fasta_entry = f">{sequence_id}\n{value}\n"
|
||||||
f.write(fasta_entry)
|
f.write(fasta_entry)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue