From 455463d21c8eab6d4fcaa47238b8be523e261d11 Mon Sep 17 00:00:00 2001 From: maxibor Date: Tue, 27 Mar 2018 14:50:36 +0200 Subject: [PATCH] fix in coverage specification --- adrsm | 3 +-- lib/adrsmlib.py | 18 +++++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/adrsm b/adrsm index d68aeb1..35f2ea8 100755 --- a/adrsm +++ b/adrsm @@ -9,7 +9,7 @@ import argparse def _get_args(): '''This function parses and return arguments passed in''' parser = argparse.ArgumentParser( - prog='ADRSM', + prog='ADRSM v0.5', description='Ancient DNA Read Simulator for Metagenomics') parser.add_argument('confFile', help="path to configuration file") parser.add_argument( @@ -127,7 +127,6 @@ if __name__ == "__main__": all_genomes = read_config(INFILE, GENDIR) for agenome in all_genomes.keys(): stat_and_run = ad.run_read_simulation_multi(INFILE=agenome, - NREAD=None, COV=all_genomes[agenome][1], READLEN=READLEN, INSERLEN=all_genomes[agenome][0], diff --git a/lib/adrsmlib.py b/lib/adrsmlib.py index 315a6c3..8fa3b78 100644 --- a/lib/adrsmlib.py +++ b/lib/adrsmlib.py @@ -30,7 +30,7 @@ def scale(x, themin, themax): def reverse_complement(dna): dna = dna.upper() ''' - Reverse complement a DNA string + Reverse complement a DNA string ''' dna = dna[::-1] revcom = [] @@ -159,13 +159,10 @@ def write_fastq_multi(fastq_dict, outputfile): f2.write(reads2) -def run_read_simulation_multi(INFILE, NREAD, COV, READLEN, INSERLEN, LENDEV, A1, A2, MINLENGTH, ERR, DAMAGE, GEOM_P, THEMIN, THEMAX, fastq_dict, QUALITY): +def run_read_simulation_multi(INFILE, COV, READLEN, INSERLEN, LENDEV, A1, A2, MINLENGTH, ERR, DAMAGE, GEOM_P, THEMIN, THEMAX, fastq_dict, QUALITY): print("===================") print("Genome: ", INFILE) - if COV: - print("Coverage: ", COV) - else: - print("Number of reads: ", NREAD) + print("Coverage: ", COV) print("Read length: ", READLEN) print("Mean Insert length: ", INSERLEN) print("Insert length standard deviation: ", LENDEV) @@ -178,15 +175,14 @@ def run_read_simulation_multi(INFILE, NREAD, COV, READLEN, INSERLEN, LENDEV, A1, basename = get_basename(INFILE) fasta = read_fasta(INFILE) - if COV: - nread = int(fasta[1] / INSERLEN) - print("Number of reads: ", nread) - print("===================\n") + nread = int((fasta[1] / INSERLEN) * COV) + print("Number of reads: ", nread) + print("===================\n") insert_lengths = [int(n) for n in npr.normal(INSERLEN, LENDEV, nread)] all_inserts = random_insert(fasta, insert_lengths, READLEN, MINLENGTH) - if DAMAGE == True: + if DAMAGE: all_inserts = add_damage( all_inserts=all_inserts, geom_p=GEOM_P,