def guess_paired_path(path):
"""
Given the path to a file that contains the sequences for the first read in a
pair, return the file that contains the sequences for the second read in a
pair. Both files must have identical names, except that the first must have
a '1' in its name, and the second must have a '2' at the same position.
Return None if no second file was found or if there are too many candidates.
>>> guess_paired_path('file.1.fastq.gz') # doctest: +SKIP
'file.2.fastq.gz' # if that file exists
"""
base, name = os.path.split(path)
glob_pattern = os.path.join(base, name.replace('1', '?'))
paths = [p for p in glob.glob(glob_pattern) if is_1_2(p, path) and '_R1_' not in p]
if len(paths) != 1:
return None
return paths[0]
评论列表
文章目录