Skip to content

Commit

Permalink
Merge pull request #9 from GenomiqueENS/gh-page
Browse files Browse the repository at this point in the history
Gh page
  • Loading branch information
alihamraoui authored Sep 3, 2024
2 parents 9e26dd2 + a139488 commit 612b508
Show file tree
Hide file tree
Showing 28 changed files with 337 additions and 1,070 deletions.
36 changes: 36 additions & 0 deletions bin/AsaruSim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import argparse
from badread_caller import badread_caller, setup_badread_command
from template_maker import template_maker, setup_template_parameters
from PCR_amplificator import PCR_amplificator, setup_PCR_parameters

def setup_parent_parser():
parent_parser = argparse.ArgumentParser(add_help=False)
parent_parser.add_argument('--debug', action='store_true', help='Enable debug mode')
return parent_parser


def main():
parent_parser = setup_parent_parser()
main_parser = argparse.ArgumentParser()

subparsers = main_parser.add_subparsers(title="command", dest="command", required=True)

subparsers.add_parser('call_badread', parents=[setup_badread_command(parent_parser)],
add_help=False)
subparsers.add_parser('template_maker', parents=[setup_template_parameters(parent_parser)],
add_help=False)
subparsers.add_parser('PCR', parents=[setup_PCR_parameters(parent_parser)],
add_help=False)

args = main_parser.parse_args()

if args.command == 'call_badread':
badread_caller(args)
if args.command == 'template_maker':
template_maker(args)
if args.command == 'PCR':
PCR_amplificator(args)


if __name__ == "__main__":
main()
71 changes: 26 additions & 45 deletions bin/PCR.py → bin/PCR_amplificator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,33 @@
import random
import os, sys, math
from toolkit import multiprocessing_submit
from toolkit import read_template

YELLOW = "\033[93m"
GRAY = "\033[90m"
RESET = "\033[0m"

logging.basicConfig(level=logging.INFO, format=GRAY+ '%(message)s' +RESET)
parser = argparse.ArgumentParser(description="Script for generating template sequences for scRNAseq simulation.")

parser.add_argument('-f','--template', type=str, required=True, help="Path to the template FASTA file.")
parser.add_argument('-o','--out', type=str, default="out.fa", help="Path to the output FASTA file.")
parser.add_argument('-c','--cycles', type=int, default=5, help="number of cycles.")
parser.add_argument('-d','--dup', type=float, default=0.7, help="duplication rate.")
parser.add_argument('-e','--error', type=float, default=0.00003, help="error rate.")
parser.add_argument('-t','--thread', type=int, default=4, help="number of threads to use.")
parser.add_argument('-b','--batch_size', type=int, default=500, help="batch size.")
parser.add_argument('-n','--totalNamber', type=int, default=None, help="total number of sequence to select from the finel pool.")
parser.add_argument('-s','--seed', type=int, default=2024, help="seed value.")


def setup_PCR_parameters(parent_parser):
description="Nanopore template maker."
if parent_parser:
parser = argparse.ArgumentParser(parents=[parent_parser],
description=description)
else :
parser = argparse.ArgumentParser(description=description)

parser.add_argument('-f','--template', type=str, required=True, help="Path to the template FASTA file.")
parser.add_argument('-o','--out', type=str, default="out.fa", help="Path to the output FASTA file.")
parser.add_argument('-c','--cycles', type=int, default=5, help="number of cycles.")
parser.add_argument('-d','--dup', type=float, default=0.7, help="duplication rate.")
parser.add_argument('-e','--error', type=float, default=0.00003, help="error rate.")
parser.add_argument('-t','--thread', type=int, default=4, help="number of threads to use.")
parser.add_argument('-b','--batch_size', type=int, default=500, help="batch size.")
parser.add_argument('-n','--totalNamber', type=int, default=None, help="total number of sequence to select from the finel pool.")
parser.add_argument('-s','--seed', type=int, default=2024, help="seed value.")
return parser

class Molecule ():
def __init__(self, name, length, seq, root, inherited_mut):
Expand Down Expand Up @@ -113,39 +123,8 @@ def PCR(template, cycles, dup_rate, error_rate, totalNumber, outfile):
sequencing(pool_list, outfile, totalNumber)


def read_template(fasta, thread, batch_size):
"""
Function to read and extract sequences from a FASTQ file. It supports both plain text and gzipped files.
Inputs:
fastq: String, path to the FASTQ file.
Returns: List of sequences encoded in ASCII.
"""
if thread==1:
with open(fasta, 'rt') as f:
while True:
header = f.readline()
if not header: break
name = header[1:].strip()
seq = f.readline().strip()
yield name, seq
else:
batch = []
with open(fasta, 'r') as f:
while True:
header = f.readline()
if not header: break
name = header[1:].strip()
seq = f.readline().strip()
batch.append([name, seq])
if len(batch) == batch_size:
yield batch
batch = []
if len(batch) > 0:
yield batch


def main():
args = parser.parse_args()
def PCR_amplificator(args):

logging.info("_____________________________")
logging.info("Template file name : %s" , args.template)
logging.info("PCR cycles : %s" , args.cycles)
Expand Down Expand Up @@ -206,4 +185,6 @@ def main():
logging.info("DONE!_______________________________")

if __name__ == "__main__":
main()
args = setup_PCR_parameters(None).parse_args()
if args:
PCR_amplificator(args)
20 changes: 9 additions & 11 deletions bin/QC.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import pandas as pd
import argparse

from libs import qc_generator
from libs.figs import over_time_graph
from libs.figs import ATGC_graph
from libs.figs import GC_content_plot
from libs.report import make_report
from libs.reporte_maker import reporter
from QC_tools import qc_generator
from QC_tools.figs import over_time_graph
from QC_tools.figs import ATGC_graph
from QC_tools.figs import GC_content_plot
from QC_tools.reporte_maker import reporter
import plotly.graph_objects as go

parser = argparse.ArgumentParser(description='Process some integers.')
Expand Down Expand Up @@ -65,8 +64,8 @@ def create_table(stats_data, table_width=500, table_height=400, margin=10):
data=[go.Table(
header=dict(
values=['', '<b>Value</b>'],
fill_color='#EBEBEB', # Couleur de fond de l'en-tête
font=dict(color='black', size=12) # Couleur et taille du texte de l'en-tête
fill_color='#EBEBEB',
font=dict(color='black', size=12)
),
cells=dict(
values=[
Expand All @@ -78,8 +77,8 @@ def create_table(stats_data, table_width=500, table_height=400, margin=10):
int(int(stats_data['Simulated UMI counts']) / int(stats_data['Simulated Cell BC']))
]
],
fill_color='#f4f4f4', # Couleur de fond des cellules
font=dict(color='black', size=11) # Couleur et taille du texte des cellules
fill_color='#f4f4f4',
font=dict(color='black', size=11)
)
)]

Expand Down Expand Up @@ -131,7 +130,6 @@ def main():
pie_fig = pie_unknown(df_stats)
stats_table = create_table(df_stats)

#make_report(Q_over_time, atgc, gc, args.project, args.positions)
reporter(stats_table,
pie_fig,
Q_over_time,
Expand Down
Binary file added bin/QC_tools/.DS_Store
Binary file not shown.
Binary file added bin/QC_tools/._.DS_Store
Binary file not shown.
Binary file added bin/QC_tools/._css_style.py
Binary file not shown.
Binary file added bin/QC_tools/._qc_generator.py
Binary file not shown.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/libs/figs.py → bin/QC_tools/figs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def make_plots(df_stats, positions, q1, q_scores, q3):
percentage_T=df_stats["%T"],
result_directory='your/directory/path',
graph_name='Base % over sequence',
yaxis_title='Q Score',
yaxis_title='Base (%)',
log=False,
sigma=1,
yaxis_starts_zero=False,
Expand Down
8 changes: 4 additions & 4 deletions bin/libs/qc_generator.py → bin/QC_tools/qc_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from tqdm import tqdm
from concurrent.futures import ProcessPoolExecutor, as_completed

from fqread.fastq_reader import SequenceStats
from QC_tools.fqread.fastq_reader import SequenceStats


def process_fastq_file(filename, pos, reverse):
Expand All @@ -16,14 +16,14 @@ def process_fastq_file(filename, pos, reverse):
with open_fn(filename[0], 'rb') as f:
while sequence_count < 100000:
header = f.readline()
if not header: break # EOF
if not header: break
if reverse:
seq = f.readline().strip()[::-1][:pos]
f.readline() # Plus line
f.readline()
quality = f.readline().strip()[::-1]
else:
seq = f.readline().strip()[:pos]
f.readline() # Plus line
f.readline()
quality = f.readline().strip()

stats.add_sequence(seq, quality)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dominate.tags import *
from dominate.util import raw
from datetime import date, datetime
from libs.css_style import body_style, head_style, div_summary_style
from QC_tools.css_style import body_style, head_style, div_summary_style

import plotly.express as px
df2 = px.data.iris()
Expand Down
Loading

0 comments on commit 612b508

Please sign in to comment.