Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 197ebed4 authored by BOULLE Olivier's avatar BOULLE Olivier
Browse files

select random fragments

parent 70d0ab55
Branches
Tags
No related merge requests found
...@@ -5,6 +5,7 @@ import sys ...@@ -5,6 +5,7 @@ import sys
import networkx as nx import networkx as nx
import time import time
import argparse import argparse
import random
# used to get the consensus fragments from a directory of fragments clusters # used to get the consensus fragments from a directory of fragments clusters
...@@ -124,7 +125,6 @@ def fragConsensus(frag_list, frag_length): ...@@ -124,7 +125,6 @@ def fragConsensus(frag_list, frag_length):
if len(cluster) != 0: if len(cluster) != 0:
clusters_list.append(cluster) clusters_list.append(cluster)
kmers_positions[kmer] = clusters_list kmers_positions[kmer] = clusters_list
# construct a list of pkmers # construct a list of pkmers
# a pkmer is an object containing a kmer & his average_position & weight # a pkmer is an object containing a kmer & his average_position & weight
# example: ACCTGAGT:23:10 # example: ACCTGAGT:23:10
...@@ -222,13 +222,15 @@ def consensusOnFragDir(frag_dir_path, output_path, frag_length, n_reads): ...@@ -222,13 +222,15 @@ def consensusOnFragDir(frag_dir_path, output_path, frag_length, n_reads):
cluster_file.close() cluster_file.close()
if n_reads is not None: if n_reads is not None:
frag_list = frag_list[:n_reads] frag_list = random.sample(frag_list, min(len(frag_list), n_reads))
consensus_sequence = fragConsensus(frag_list, frag_length) consensus_sequence = fragConsensus(frag_list, frag_length)
#if len(consensus_sequence) >= 2*frag_length/3: #if len(consensus_sequence) >= 2*frag_length/3:
consensus_file.write(">consensus_of_"+cluster_filename+"\n") consensus_file.write(">consensus_of_"+cluster_filename+"\n")
consensus_file.write(consensus_sequence+"\n") consensus_file.write(consensus_sequence+"\n")
#if len(consensus_sequence) < 2*frag_length/3:
#print(cluster_filename)
computed_consensus += 1 computed_consensus += 1
consensus_file.close() consensus_file.close()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment