MCPcopy Create free account
hub / github.com/OpenGene/fastp / processDir

Function processDir

parallel.py:51–153  ·  view source on GitHub ↗
(folder, options)

Source from the content-addressed store, hash-verified

49 return filename[:-len(ext)]
50
51def processDir(folder, options):
52 fqext = (".fq", ".fastq", ".fq.gz", ".fastq.gz")
53 read1name = options.read1_flag
54 read2name = options.read2_flag
55
56 #is not a dir
57 if not os.path.isdir(folder):
58 return
59
60 options_list = []
61 processed = set() # to avoid processing the same file multiple times
62
63 files = os.listdir(folder)
64 for f in files:
65 path = os.path.join(folder, f)
66 if os.path.isdir(path):
67 continue
68
69 isfq = False
70 for ext in fqext:
71 if f.endswith(ext):
72 isfq = True
73 if isfq == False:
74 continue
75
76 if processed.__contains__(path):
77 continue
78
79 # skip read2 files here, we will find read1 files first
80 if matchFlag(f, read2name):
81 continue
82
83 processed.add(path)
84
85 # here we skip those files with name starting with Undetermined
86 # because these files are usually with unknown barcode and have no need to be processed
87 if f.startswith("Undetermined"):
88 continue
89
90 #find read1 file, try to find read2 file
91 if matchFlag(f, read1name):
92 opt = copy.copy(options)
93 read1 = path
94 opt.read1_file = read1
95 read2 = read1.replace(read1name, read2name)
96 if os.path.exists(read2):
97 opt.read2_file = read2
98 processed.add(read2)
99 options_list.append(opt)
100 else:
101 # if not read1 file, then run fastp as single-end
102 opt = copy.copy(options)
103 opt.read1_file = path
104 options_list.append(opt)
105
106 commands = []
107 for opt in options_list:
108 cmd = ""

Callers 1

mainFunction · 0.85

Calls 3

matchFlagFunction · 0.85
getBaseNameFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected