OSCR

Microbiome functional gene pathways are indicative of cognitive performance in older adults at risk for Alzheimer's disease.

Code ↔ Paper

1 match between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 1 match
  1. [1] § Materials and methods › Sample handling and DNA sequencing ↔ kneaddata/knead_data.py, lines 3–40 · score 0.67 · Quality control, KneadData, tools, Metagenomic, contamination, host

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

Python · 613 lines · 25 KB · MIT · 1 match

  1. #!/usr/bin/env python
  2. """
  3. KneadData
  4. KneadData is a tool designed to perform quality control on metagenomic
  5. sequencing data, especially data from microbiome experiments. In these
  6. experiments, samples are typically taken from a host in hopes of learning
  7. something about the microbial community on the host. However, metagenomic
  8. sequencing data from such experiments will often contain a high ratio of host
  9. to bacterial reads. This tool aims to perform principled in silico separation
  10. of bacterial reads from these "contaminant" reads, be they from the host,
  11. from bacterial 16S sequences, or other user-defined sources.
  12. Dependencies: Trimmomatic, Bowtie2 or BMTagger, and TRF (optional)
  13. To Run: kneaddata -i <input.fastq> -o <output_dir>
  14. Copyright (c) 2015 Harvard School of Public Health
  15. Permission is hereby granted, free of charge, to any person obtaining a copy
  16. of this software and associated documentation files (the "Software"), to deal
  17. in the Software without restriction, including without limitation the rights
  18. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19. copies of the Software, and to permit persons to whom the Software is
  20. furnished to do so, subject to the following conditions:
  21. The above copyright notice and this permission notice shall be included in
  22. all copies or substantial portions of the Software.
  23. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  27. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  28. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  29. THE SOFTWARE.
  30. """
  31. import sys
  32. # check for the required python version
  33. required_python_version_major = 2
  34. required_python_version_minor = 7
  35. try:
  36. if (sys.version_info[0] < required_python_version_major or
  37. (sys.version_info[0] == required_python_version_major and
  38. sys.version_info[1] < required_python_version_minor)):
  39. sys.exit("CRITICAL ERROR: The python version found (version "+
  40. str(sys.version_info[0])+"."+str(sys.version_info[1])+") "+
  41. "does not match the version required (version "+
  42. str(required_python_version_major)+"."+
  43. str(required_python_version_minor)+"+)")
  44. except (AttributeError,IndexError):
  45. sys.exit("CRITICAL ERROR: The python version found (version 1) " +
  46. "does not match the version required (version "+
  47. str(required_python_version_major)+"."+
  48. str(required_python_version_minor)+"+)")
  49. import os
  50. import logging
  51. import argparse
  52. import re
  53. import itertools
  54. # Try to load one of the kneaddata modules to check the installation
  55. try:
  56. from kneaddata import utilities
  57. except ImportError:
  58. sys.exit("ERROR: Unable to find the kneaddata python package." +
  59. " Please check your install.")
  60. from kneaddata import run
  61. from kneaddata import config
  62. VERSION="0.12.4"
  63. # name global logging instance
  64. logger=logging.getLogger(__name__)
  65. # Global input files path list for FASTQC
  66. original_input_files=[]
  67. def parse_arguments(args):
  68. """
  69. Parse the arguments from the user
  70. """
  71. parser = argparse.ArgumentParser(
  72. description= "KneadData\n",
  73. formatter_class=argparse.RawTextHelpFormatter,
  74. prog="kneaddata")
  75. group1 = parser.add_argument_group("global options")
  76. group1.add_argument(
  77. "--version",
  78. action="version",
  79. version="%(prog)s v"+VERSION)
  80. parser.add_argument(
  81. "-v","--verbose",
  82. action="store_true",
  83. help="additional output is printed\n")
  84. group1.add_argument(
  85. "-i1", "--input1",
  86. help="Pair 1 input FASTQ file",
  87. dest='input1')
  88. group1.add_argument(
  89. "-i2", "--input2",
  90. help="Pair 2 input FASTQ file",
  91. dest='input2')
  92. group1.add_argument(
  93. "-un","--unpaired",
  94. help="unparied input FASTQ file",
  95. dest='unpaired')
  96. group1.add_argument(
  97. "-o", "--output",
  98. dest='output_dir',
  99. help="directory to write output files",
  100. required=True)
  101. group1.add_argument(
  102. "-s", "--scratch",
  103. dest='scratch_dir',
  104. help="directory to write temp files",
  105. default="")
  106. group1.add_argument(
  107. "-db", "--reference-db",
  108. default=[], action="append",
  109. help="location of reference database (additional arguments add databases)")
  110. group1.add_argument(
  111. "--bypass-trim",
  112. action="store_true",
  113. help="bypass the trim step")
  114. group1.add_argument(
  115. "--output-prefix",
  116. help="prefix for all output files\n[ DEFAULT : $SAMPLE_kneaddata ]")
  117. group1.add_argument(
  118. "-t","--threads",
  119. type=int,
  120. default=config.threads,
  121. metavar="<" + str(config.threads) + ">",
  122. help="number of threads\n[ Default : "+str(config.threads)+" ]")
  123. group1.add_argument(
  124. "-p","--processes",
  125. type=int,
  126. default=config.processes,
  127. metavar="<" + str(config.processes) + ">",
  128. help="number of processes\n[ Default : "+str(config.processes)+" ]")
  129. group1.add_argument(
  130. "-q","--quality-scores",
  131. default=config.quality_scores,
  132. choices=config.quality_scores_options,
  133. dest='trimmomatic_quality_scores',
  134. help="quality scores\n[ DEFAULT : "+config.quality_scores+" ]")
  135. group1.add_argument(
  136. "--run-bmtagger",
  137. default=False,
  138. action="store_true",
  139. dest='bmtagger',
  140. help="run BMTagger instead of Bowtie2 to identify contaminant reads")
  141. group1.add_argument(
  142. "--bypass-trf",
  143. action="store_true",
  144. help="option to bypass the removal of tandem repeats")
  145. group1.add_argument(
  146. "--run-trf",
  147. action="store_true",
  148. help="legacy option to run the removal of tandem repeats (now run by default)")
  149. group1.add_argument(
  150. "--run-fastqc-start",
  151. default=False,
  152. dest='fastqc_start',
  153. action="store_true",
  154. help="run fastqc at the beginning of the workflow")
  155. group1.add_argument(
  156. "--run-fastqc-end",
  157. default=False,
  158. dest='fastqc_end',
  159. action="store_true",
  160. help="run fastqc at the end of the workflow")
  161. group1.add_argument(
  162. "--store-temp-output",
  163. action="store_true",
  164. help="store temp output files\n[ DEFAULT : temp output files are removed ]")
  165. group1.add_argument(
  166. "--remove-intermediate-output",
  167. action="store_true",
  168. help="remove intermediate output files\n[ DEFAULT : intermediate output files are stored ]")
  169. group1.add_argument(
  170. "--cat-final-output",
  171. action="store_true",
  172. help="concatenate all final output files\n[ DEFAULT : final output is not concatenated ]")
  173. group1.add_argument(
  174. "--log-level",
  175. default=config.log_level,
  176. choices=config.log_level_choices,
  177. help="level of log messages\n[ DEFAULT : "+config.log_level+" ]")
  178. group1.add_argument(
  179. "--log",
  180. help="log file\n[ DEFAULT : $OUTPUT_DIR/$SAMPLE_kneaddata.log ]")
  181. group2 = parser.add_argument_group("trimmomatic arguments")
  182. group2.add_argument(
  183. "--trimmomatic",
  184. dest='trimmomatic_path',
  185. help="path to trimmomatic\n[ DEFAULT : $PATH ]")
  186. group2.add_argument(
  187. "--run-trim-repetitive",
  188. default=False,
  189. dest='run_trim_repetitive',
  190. action="store_true",
  191. help="Trim fastqc generated overrepresented sequences\n")
  192. group2.add_argument(
  193. "--max-memory",
  194. default=config.trimmomatic_memory,
  195. help="max amount of memory\n[ DEFAULT : "+config.trimmomatic_memory+" ]")
  196. group2.add_argument(
  197. "--trimmomatic-options",
  198. action="append",
  199. help="options for trimmomatic\n[ DEFAULT : "+" ".join(utilities.get_default_trimmomatic_options())+" ]\n"+\
  200. "MINLEN is set to "+str(config.trimmomatic_min_len_percent)+" percent of total input read length. The user can alternatively specify a length (in bases) for MINLEN.")
  201. group2.add_argument(
  202. "--sequencer-source",
  203. dest='sequencer_source',
  204. default=config.trimmomatic_provided_sequencer_default,
  205. choices=config.trimmomatic_provided_sequencer_source,
  206. help="options for sequencer-source\n[ DEFAULT : "+config.trimmomatic_provided_sequencer_default+"]")
  207. group3 = parser.add_argument_group("bowtie2 arguments")
  208. group3.add_argument(
  209. "--bowtie2",
  210. dest='bowtie2_path',
  211. help="path to bowtie2\n[ DEFAULT : $PATH ]")
  212. group3.add_argument(
  213. "--bowtie2-options",
  214. action="append",
  215. help="options for bowtie2\n[ DEFAULT : "+ " ".join(config.bowtie2_options)+" ]")
  216. group3.add_argument(
  217. "--decontaminate-pairs",
  218. choices=["strict","lenient","unpaired"],
  219. default="strict",
  220. help="options for filtering of paired end reads (strict='remove both R1+R2 if either align', lenient='remove only if both R1+R2 align', unpaired='ignore pairing and remove as single end')\n"+\
  221. "[ DEFAULT : %(default)s ]")
  222. group3.add_argument(
  223. "--reorder",
  224. action="store_true",
  225. help="order the sequences in the same order as the input\n[ DEFAULT : Sequences are not ordered ]")
  226. group3.add_argument(
  227. "--serial",
  228. action="store_true",
  229. help="filter the input in serial for multiple databases so a subset of reads are processed in each database search (the default when running with a single process)")
  230. group4 = parser.add_argument_group("bmtagger arguments")
  231. group4.add_argument(
  232. "--bmtagger",
  233. dest='bmtagger_path',
  234. help="path to BMTagger\n[ DEFAULT : $PATH ]")
  235. group5 = parser.add_argument_group("trf arguments")
  236. group5.add_argument(
  237. "--trf",
  238. dest='trf_path',
  239. help="path to TRF\n[ DEFAULT : $PATH ]")
  240. group5.add_argument(
  241. "--match",
  242. type=int,
  243. default=config.trf_match,
  244. help="matching weight\n[ DEFAULT : "+str(config.trf_match)+" ]")
  245. group5.add_argument(
  246. "--mismatch",
  247. type=int,
  248. default=config.trf_mismatch,
  249. help="mismatching penalty\n[ DEFAULT : "+str(config.trf_mismatch)+" ]")
  250. group5.add_argument(
  251. "--delta",
  252. type=int,
  253. default=config.trf_delta,
  254. help="indel penalty\n[ DEFAULT : "+str(config.trf_delta)+" ]")
  255. group5.add_argument(
  256. "--pm",
  257. type=int,
  258. default=config.trf_match_probability,
  259. help="match probability\n[ DEFAULT : "+str(config.trf_match_probability)+" ]")
  260. group5.add_argument(
  261. "--pi",
  262. type=int,
  263. default=config.trf_pi,
  264. help="indel probability\n[ DEFAULT : "+str(config.trf_pi)+" ]")
  265. group5.add_argument(
  266. "--minscore",
  267. type=int,
  268. default=config.trf_minscore,
  269. help="minimum alignment score to report\n[ DEFAULT : "+str(config.trf_minscore)+" ]")
  270. group5.add_argument(
  271. "--maxperiod",
  272. type=int,
  273. default=config.trf_maxperiod,
  274. help="maximum period size to report\n[ DEFAULT : "+str(config.trf_maxperiod)+" ]")
  275. group6 = parser.add_argument_group("fastqc arguments")
  276. group6.add_argument(
  277. "--fastqc",
  278. dest='fastqc_path',
  279. help="path to fastqc\n[ DEFAULT : $PATH ]")
  280. return parser.parse_args()
  281. def update_configuration(args):
  282. """ Update the run settings based on the arguments provided """
  283. # if only a single processor is to be used, default to serial mode for efficiency
  284. if args.processes == 1:
  285. args.serial=True
  286. # get the full path for the output directory
  287. args.output_dir = os.path.abspath(args.output_dir)
  288. if args.scratch_dir:
  289. args.scratch_dir = os.path.abspath(args.scratch_dir)
  290. # set if temp output should be removed
  291. args.remove_temp_output = not args.store_temp_output
  292. # if intermediate output should be removed, then also remove temp output
  293. if args.remove_intermediate_output:
  294. args.remove_temp_output = True
  295. # check the input files are non-empty and readable
  296. args.input=[]
  297. if (args.input1 and args.input2):
  298. args.input.append(os.path.abspath(args.input1))
  299. args.input.append(os.path.abspath(args.input2))
  300. if (args.unpaired):
  301. args.input.append(os.path.abspath(args.unpaired))
  302. utilities.is_file_readable(args.input[0],exit_on_error=True)
  303. if len(args.input) == 2:
  304. utilities.is_file_readable(args.input[1],exit_on_error=True)
  305. elif len(args.input) > 2:
  306. sys.exit("ERROR: Please provide at most 2 input files.")
  307. elif len(args.input) == 0:
  308. sys.exit("ERROR: Please provide --input1/--input2 or --unpaired (input) files.")
  309. #Store original file paths for FASTQC
  310. for input in args.input:
  311. original_input_files.append(input)
  312. # create the output directory and scratch if needed
  313. utilities.create_directory(args.output_dir)
  314. if args.scratch_dir:
  315. utilities.create_directory(args.scratch_dir)
  316. # set bowtie2 options
  317. if args.bowtie2_options:
  318. # parse the options from the user into any array of options
  319. args.bowtie2_options=utilities.format_options_to_list(args.bowtie2_options)
  320. else:
  321. # if not set by user, then set to default options
  322. args.bowtie2_options = config.bowtie2_options
  323. # add the quality scores to the bowtie2 options
  324. args.bowtie2_options+=[config.bowtie2_flag_start+args.trimmomatic_quality_scores]
  325. # set the mode for single end input file
  326. if len(args.input) == 1:
  327. args.decontaminate_pairs = "unpaired"
  328. # set the bowtie2 mode based on the pairs input
  329. args.discordant = False
  330. if args.decontaminate_pairs != "lenient" :
  331. args.discordant = True
  332. # update the quality score option into a flag for trimmomatic
  333. args.trimmomatic_quality_scores=config.trimmomatic_flag_start+args.trimmomatic_quality_scores
  334. # find the location of trimmomatic, trimmomatic does not need to be executable
  335. if not args.bypass_trim:
  336. args.trimmomatic_path=utilities.find_dependency(args.trimmomatic_path,config.trimmomatic_jar,"trimmomatic",
  337. "--trimmomatic", bypass_permissions_check=True)
  338. # find the location of bmtagger, if set to run
  339. if args.reference_db:
  340. if args.bmtagger:
  341. args.bmtagger_path=utilities.find_dependency(args.bmtagger_path,config.bmtagger_exe,"bmtagger",
  342. "--bmtagger", bypass_permissions_check=False)
  343. # add this folder to path, so as to be able to find other dependencies like bmfilter
  344. utilities.add_exe_to_path(os.path.dirname(args.bmtagger_path))
  345. else:
  346. # find the location of bowtie2, if not running with bmtagger
  347. args.bowtie2_path=utilities.find_dependency(args.bowtie2_path, config.bowtie2_exe, "bowtie2",
  348. "--bowtie2", bypass_permissions_check=False)
  349. # find the location of trf, if set to run
  350. if not args.bypass_trf:
  351. args.trf_path=utilities.find_dependency(args.trf_path,config.trf_exe,"trf",
  352. "--trf", bypass_permissions_check=False)
  353. # if fastqc is set to be run, check if the executable can be found
  354. if args.fastqc_start or args.fastqc_end or args.run_trim_repetitive:
  355. args.fastqc_path=utilities.find_dependency(args.fastqc_path,config.fastqc_exe,"fastqc",
  356. "--fastqc",bypass_permissions_check=False)
  357. # set the default output prefix
  358. if args.output_prefix == None:
  359. if args.input[0].endswith(".gz") or args.input[0].endswith(".bz2"):
  360. # remove compression extension if present
  361. infile_base = os.path.splitext(os.path.splitext(os.path.basename(args.input[0]))[0])[0]
  362. else:
  363. infile_base = os.path.splitext(os.path.basename(args.input[0]))[0]
  364. args.output_prefix = infile_base + "_kneaddata"
  365. # find the bowtie2 indexes for each of the reference databases
  366. # reference database inputs can be directories, indexes, or index files
  367. if args.reference_db:
  368. reference_indexes=[]
  369. database_type="bowtie2"
  370. if args.bmtagger:
  371. database_type="bmtagger"
  372. for directory in args.reference_db:
  373. reference_indexes.append(utilities.find_database_index(os.path.abspath(directory),database_type))
  374. args.reference_db=reference_indexes
  375. return args
  376. def setup_logging(args):
  377. """ Set up the log file """
  378. if not args.log:
  379. args.log = os.path.join(args.output_dir,args.output_prefix+".log")
  380. # configure the logger
  381. logging.basicConfig(filename=args.log,format='%(asctime)s - %(name)s - %(levelname)s: %(message)s',
  382. level=getattr(logging,args.log_level), filemode='w', datefmt='%m/%d/%Y %I:%M:%S %p')
  383. # write the version of the software to the log
  384. logger.info("Running kneaddata v"+VERSION)
  385. # write the location of the output files to the log
  386. message="Output files will be written to: " + args.output_dir
  387. logger.info(message)
  388. # write out all of the argument settings
  389. message="Running with the following arguments: \n"
  390. for key,value in vars(args).items():
  391. if isinstance(value,list) or isinstance(value,tuple):
  392. value_string=" ".join([str(i) for i in value])
  393. else:
  394. value_string=str(value)
  395. message+=key+" = "+value_string+"\n"
  396. logger.debug(message)
  397. def main():
  398. # Parse the arguments from the user
  399. args = parse_arguments(sys.argv)
  400. # Update the configuration
  401. args = update_configuration(args)
  402. # Start logging
  403. setup_logging(args)
  404. # set the prefix for the output files
  405. final_output_dir = args.output_dir
  406. if args.scratch_dir:
  407. full_path_output_prefix = os.path.join(args.scratch_dir, args.output_prefix)
  408. args.output_dir = args.scratch_dir
  409. else:
  410. full_path_output_prefix = os.path.join(args.output_dir, args.output_prefix)
  411. temp_output_files=[]
  412. # Check for compressed files, bam files, or sam files
  413. for index in range(len(args.input)):
  414. # check for gzipped/bz2 files
  415. if args.input[index].endswith(".gz") or args.input[index].endswith(".bz2"):
  416. args.input[index]=utilities.get_decompressed_file(args.input[index], args.output_dir, temp_output_files, args.input)
  417. elif args.input[index].endswith(".bam"):
  418. input_files_set=utilities.get_fastq_from_bam_file(args.input[index], args.output_dir, temp_output_files, args.input)
  419. if isinstance(input_files_set,list):
  420. args.input=input_files_set
  421. else:
  422. args.input[index]=input_files_set
  423. elif args.input[index].endswith(".sam"):
  424. args.input[index]=utilities.get_fastq_from_sam_file(args.input[index], args.output_dir, temp_output_files, args.input)
  425. # Get the format of the first input file
  426. file_format=utilities.get_file_format(args.input[0])
  427. if file_format != "fastq":
  428. message="Your input file is of type: "+file_format+". Please provide an input file of fastq format."
  429. logger.critical(message)
  430. sys.exit(message)
  431. # if this is the new illumina identifier format, create temp files after reformatting the headers
  432. for index in range(len(args.input)):
  433. args.input[index]=utilities.get_reformatted_identifiers(args.input[index],index,args.output_dir, temp_output_files, args.input)
  434. # check for reads that are not ordered and order if needed (if trimmomatic is run)
  435. if not args.bypass_trim and len(args.input)==2:
  436. args.input=utilities.check_and_reorder_reads(args.input, args.output_dir, temp_output_files)
  437. # remove any temp files from decompress/reformat that are no longer needed
  438. utilities.update_temp_output_files(temp_output_files, [], args.input)
  439. # set trimmomatic options
  440. # this is done after the decompression and conversions from sam/bam
  441. # as the default requires the read length from the input sequences
  442. if args.trimmomatic_options:
  443. # parse the options from the user into an array of options
  444. args.trimmomatic_options = utilities.format_options_to_list(args.trimmomatic_options)
  445. else:
  446. # if trimmomatic options not set by user, then set to default options
  447. # use read length of input file for minlen
  448. args.trimmomatic_options = utilities.get_default_trimmomatic_options(utilities.get_read_length_fastq(args.input[0]),
  449. path=config.trimmomatic_adapter_folder,type="PE" if len(args.input) == 2 else "SE", sequencer_source=args.sequencer_source)
  450. # Get the number of reads initially
  451. utilities.log_read_count_for_files(args.input,"raw","Initial number of reads",args.verbose)
  452. # Run fastqc if set to run at start of workflow
  453. if args.fastqc_start or args.run_trim_repetitive:
  454. run.fastqc(args.fastqc_path, args.output_dir, original_input_files, args.threads, args.verbose)
  455. #Setting fastqc output zip and txt file path
  456. output_txt_files=[]
  457. for input_file_name in original_input_files:
  458. temp_file = os.path.splitext(input_file_name)[0]
  459. if (temp_file.count('fastq')>0 or temp_file.count('fq')>0 ):
  460. temp_file = os.path.splitext(temp_file)[0]
  461. output_txt_files.append(args.output_dir+"/fastqc/"+temp_file.split('/')[-1]+"_fastqc/fastqc_data.txt")
  462. if not args.bypass_trim:
  463. if args.run_trim_repetitive:
  464. # Get the Min Overrepresented Seq Length
  465. args.trimmomatic_options = utilities.get_updated_trimmomatic_parameters(output_txt_files, args.output_dir, args.trimmomatic_options)
  466. trimmomatic_output_files = run.trim(
  467. args.input, full_path_output_prefix, args.trimmomatic_path,
  468. args.trimmomatic_quality_scores, args.max_memory, args.trimmomatic_options,
  469. args.threads, args.verbose)
  470. else:
  471. message="Bypass trimming"
  472. logger.info(message)
  473. print(message)
  474. trimmomatic_output_files=[args.input]
  475. # Get the number of reads after trimming
  476. utilities.log_read_count_for_files(trimmomatic_output_files,"trimmed","Total reads after trimming",args.verbose)
  477. # run TRF, if set
  478. if not args.bypass_trf:
  479. # run trf on all output files
  480. trf_output_files=run.tandem(trimmomatic_output_files, full_path_output_prefix, args.match,
  481. args.mismatch,args.delta,args.pm,args.pi,
  482. args.minscore,args.maxperiod,args.trf_path,
  483. args.processes,args.verbose,args.remove_temp_output,args.threads)
  484. # remove the aligment files, if intermediate output files should be removed
  485. if args.reference_db and args.remove_intermediate_output:
  486. temp_output_files+=utilities.resolve_sublists(trimmomatic_output_files)
  487. else:
  488. trf_output_files = trimmomatic_output_files
  489. # If a reference database is not provided, then bypass decontamination step
  490. if not args.reference_db:
  491. message="Bypass decontamination"
  492. logger.info(message)
  493. print(message)
  494. # resolve sub-lists if present
  495. final_output_files=trf_output_files
  496. else:
  497. final_output_files=run.decontaminate(args, full_path_output_prefix, trf_output_files)
  498. # remove trimmed output files, if set to remove intermediate outputx
  499. if not args.bypass_trim and args.remove_intermediate_output:
  500. temp_output_files+=utilities.resolve_sublists(trf_output_files)
  501. # If set, concat the final output files if there is more than one
  502. final_output_files = utilities.resolve_sublists(final_output_files)
  503. if args.cat_final_output and len(final_output_files) > 1:
  504. cat_output_file=full_path_output_prefix+config.fastq_file_extension
  505. utilities.cat_files(final_output_files,cat_output_file)
  506. # if removing intermediate output, then remove the files that were merged
  507. if args.remove_intermediate_output:
  508. temp_output_files+=final_output_files
  509. final_output_files=[cat_output_file]
  510. else:
  511. final_output_files.append(cat_output_file)
  512. # Remove any temp output files, if set
  513. if not args.store_temp_output:
  514. for file in temp_output_files:
  515. utilities.remove_file(file)
  516. # Run fastqc if set to run at end of workflow
  517. if args.fastqc_end:
  518. run.fastqc(args.fastqc_path, args.output_dir, final_output_files, args.threads, args.verbose)
  519. # If using scratch, then move final output files to output folder
  520. if args.scratch_dir:
  521. scratch_output_files=final_output_files
  522. final_output_files=[]
  523. for outfile in scratch_output_files:
  524. utilities.move_file(os.path.basename(outfile),args.output_dir,final_output_dir)
  525. final_output_files.append(os.path.join(final_output_dir,os.path.basename(outfile)))
  526. if len(final_output_files) > 1:
  527. message="\nFinal output files created: \n"
  528. else:
  529. message="\nFinal output file created: \n"
  530. message=message+ "\n".join(final_output_files) + "\n"
  531. logger.info(message)
  532. print(message)
  533. if __name__ == '__main__':
  534. main()

knead_data.py at commit af84ded, under MIT · at the source

Overview

Authors: Abigail L. Zeamer1,2, YuShuan Lai1,2, Ethan Loew1, Victoria Sanborn3, Matthew Tracy1, Cynthia Jo4, Danielle Ferdinand4, Doyle V. Ward1,2, Shakti K. Bhattarai1,2, Johnathan Drake3, Beth A. McCormick1,2, Vanni Bucci1,2, John P. Haran1,2,4
  1. Department of Microbiology, University of Massachusetts Chan Medical School, Worcester, MA, USA
  2. Program in Microbiome Dynamics, University of Massachusetts Chan Medical School, Worcester, MA, USA
  3. Rhode Island Hospital, Providence, Rhode Island, USA
  4. Department of Emergency Medicine, University of Massachusetts Chan Medical School, Worcester, MA, USA
Institutions: University of Massachusetts Chan Medical School (United States); Rhode Island Hospital (United States)
Journal: Gut microbes, volume 18, issue 1, article 2676162
Dates: published online 24 May 2026; in print December 2026
Type: Data paper · Language: English
License: CC BY
Identifiers: DOI 10.1080/19490976.2026.2676162 · PMID 42178714 · PMCID PMC13203045 · OpenAlex W7162288588
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: human (organism), Alzheimer's / dementia (population)
Methods: Statistics, Machine learning, Preprocessing, Connectivity
Keywords: Alzheimer's disease, mild cognitive impairment, cognition, ADAS-Cog, clinical dementia rating (CDR) scale, NIH toolbox, memory, executive function, microbiome, methionine, putrescine, polyamines, cysteine, urea cycle, folate, vitamin B12
MeSH: Alzheimer Disease*, Bacteria*, Cognition*, Cognitive Dysfunction*, Gastrointestinal Microbiome*, Aged, Aged, 80 and over, Female, Humans, Male, Metabolic Networks and Pathways, Middle Aged (* major topic)
Journal subjects: Data Note
Topic: Gut microbiota and health (Molecular Biology, Biochemistry, Genetics and Molecular Biology), according to OpenAlex
Funding: Gates Family Foundation; National Institute of Allergy and Infectious Diseases (U01 AI172987); National Institute on Aging (2019-AARG-NTF-641955 and R01AG067483-01); Alzheimer’s Association (2019-AARG-NTF-641955)
Citations: not cited yet (Europe PMC); 114 references in the paper

Abstract

Disturbances in the gut microbiome are increasingly correlated with neurodegenerative disorders, including Alzheimer's disease. Multiple lines of emerging evidence are consistent with the microbiome's involvement in disease pathology in AD by triggering or potentiating systemic and neuroinflammation, thereby influencing disease pathology through the “microbiota–gut–brain axis.” Currently, the copathologies contributing to cognitive decline and symptomatic progression in AD remain unknown and understudied. Changes in the gut microbiome composition may offer clues to potential systemic physiologic and neuropathologic changes that contribute to cognitive decline. Here, we recruited a cohort of 260 older adults (aged 60 y or older) living in the community and followed them over time, tracking objective measures of cognition, clinical information, and gut microbiome samples. Subjects were classified as healthy controls, exhibiting mild cognitive impairment, or having dementia based on clinical assessments. Using metagenomic sequencing and gene pathway analyses, we found that certain microbial-encoded metabolic pathways correlated with worse cognitive performance. Specifically, genes involved in the urea cycle, polyamine synthesis, or the metabolism of methionine and cysteine predicted worse cognitive performance. Our study suggests that the gut microbiome composition may be linked to cognitive impairment along the AD continuum and points to microbial metabolic pathways that may potentiate disease.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repository

Its files are read in the Code ↔ Paper reader above, with 1 match between paragraphs and lines of code.

biobakery/kneaddata

License: MIT
State: the link answers, verified on 28 September 2026
Evidence: files inventoried
Commit: af84ded250ba2f046c57e76bb66d59d542f541ab, 10 July 2026
Languages: Python (28)
Size: 62 files, 28 scripts
Software Heritage: archived
Found in: the text, “Sample handling and DNA sequencing”
Holds: README, license file, environment (setup.py), tests, continuous integration
Not found: CITATION.cff, documentation
Tools: Biopython (1 file)
Availability: 1 check, the latest on 28 September 2026: the link answers
  • 28 September 2026: the link answers
30 files

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 28 scripts, each with its path and the digest of its content;
  • 1 match between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

No dataset and no data link were found in the paper.

Data availability statement

Microbiome sequencing and related metadata are available on NCBI (BioProject ID PRJNA1446836).

Reproduced under the paper's license (CC BY), from the paper cited above.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 28 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 13 authors, 16 keywords, 12 MeSH terms, 4 funders, 109 references.

Cite

This paper

Zeamer, A. L., Lai, Y., Loew, E., Sanborn, V., Tracy, M., Jo, C., Ferdinand, D., Ward, D. V., Bhattarai, S. K., Drake, J., McCormick, B. A., Bucci, V., & Haran, J. P. (2026). Microbiome functional gene pathways are indicative of cognitive performance in older adults at risk for Alzheimer's disease. Gut microbes, 18(1), 2676162. https://doi.org/10.1080/19490976.2026.2676162

BibTeX

@article{zeamer2026microbiome,
author = {Zeamer, Abigail L. and Lai, YuShuan and Loew, Ethan and Sanborn, Victoria and Tracy, Matthew and Jo, Cynthia and Ferdinand, Danielle and Ward, Doyle V. and Bhattarai, Shakti K. and Drake, Johnathan and McCormick, Beth A. and Bucci, Vanni and Haran, John P.},
title = {{Microbiome functional gene pathways are indicative of cognitive performance in older adults at risk for Alzheimer's disease}},
journal = {Gut microbes},
year = {2026},
month = may,
volume = {18},
number = {1},
pages = {2676162},
publisher = {Taylor \& Francis},
issn = {1949-0976},
doi = {10.1080/19490976.2026.2676162},
url = {https://doi.org/10.1080/19490976.2026.2676162},
pmid = {42178714},
pmcid = {PMC13203045}
}

RIS

TY - JOUR
AU - Zeamer, Abigail L.
AU - Lai, YuShuan
AU - Loew, Ethan
AU - Sanborn, Victoria
AU - Tracy, Matthew
AU - Jo, Cynthia
AU - Ferdinand, Danielle
AU - Ward, Doyle V.
AU - Bhattarai, Shakti K.
AU - Drake, Johnathan
AU - McCormick, Beth A.
AU - Bucci, Vanni
AU - Haran, John P.
TI - Microbiome functional gene pathways are indicative of cognitive performance in older adults at risk for Alzheimer's disease
T2 - Gut microbes
J2 - Gut Microbes
PY - 2026
DA - 2026/05/24
VL - 18
IS - 1
SP - 2676162
SN - 1949-0976
PB - Taylor & Francis
DO - 10.1080/19490976.2026.2676162
UR - https://doi.org/10.1080/19490976.2026.2676162
LA - en
ER -

CSL-JSON

{
"id": "10.1080/19490976.2026.2676162",
"type": "article-journal",
"title": "Microbiome functional gene pathways are indicative of cognitive performance in older adults at risk for Alzheimer's disease",
"container-title": "Gut microbes",
"author": [
{
"family": "Zeamer",
"given": "Abigail L."
},
{
"family": "Lai",
"given": "YuShuan"
},
{
"family": "Loew",
"given": "Ethan"
},
{
"family": "Sanborn",
"given": "Victoria"
},
{
"family": "Tracy",
"given": "Matthew"
},
{
"family": "Jo",
"given": "Cynthia"
},
{
"family": "Ferdinand",
"given": "Danielle"
},
{
"family": "Ward",
"given": "Doyle V."
},
{
"family": "Bhattarai",
"given": "Shakti K."
},
{
"family": "Drake",
"given": "Johnathan"
},
{
"family": "McCormick",
"given": "Beth A."
},
{
"family": "Bucci",
"given": "Vanni"
},
{
"family": "Haran",
"given": "John P."
}
],
"container-title-short": "Gut Microbes",
"volume": "18",
"issue": "1",
"page": "2676162",
"DOI": "10.1080/19490976.2026.2676162",
"PMID": "42178714",
"PMCID": "PMC13203045",
"ISSN": "1949-0976",
"publisher": "Taylor & Francis",
"URL": "https://doi.org/10.1080/19490976.2026.2676162",
"language": "en",
"issued": {
"date-parts": [
[
2026,
5,
24
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1186/s40168-026-02342-8 [code]
Impacts of host genetics on gut microbiome composition in Alzheimer's disease.
Journal: Microbiome
In common: Alzheimer's / dementia, 5 references
[2] doi:10.1038/s41467-026-74775-6
Select microbial metabolites promote tau aggregation in a murine tauopathy model.
Journal: Nature communications
In common: Alzheimer's / dementia, 3 references
[3] doi:10.64898/2026.03.09.710596 [code]
Infant gut microbiomes contribute to metabolic states that impact brain function
Journal: bioRxiv (preprint)
In common: Biopython, 2 references
[4] doi:10.1016/j.tjpad.2026.100601
Identification of a CD44-dependent control of astrocytic autophagic activity in Alzheimer's disease.
Journal: The journal of prevention of Alzheimer's disease
In common: Alzheimer's / dementia, 4 references
[5] doi:10.1016/j.dcn.2026.101744 [code]
The longitudinal structure of cognition in the ABCD study and associations with neural function and psychopathology: A Bayesian probabilistic principal components analysis.
Journal: Developmental cognitive neuroscience
In common: 3 references
[6] doi:10.1038/s41746-026-02732-0 [code]
A dynamic risk prediction framework for Alzheimer's disease and related dementias with interpretability.
Journal: NPJ digital medicine
In common: Alzheimer's / dementia, 3 references
[7] doi:10.1016/j.bbih.2026.101275 [code]
A protocol for the Teen Bugs study: An integrative, multi-omics approach to understanding the role of the gut microbiome and mesocorticolimbic system in adolescent mental health following early adverse caregiving.
Journal: Brain, behavior, & immunity - health
In common: 3 references
[8] doi:10.1038/s41540-026-00677-4
Neuro-Dynamic Quantitative Systems Pharmacology (QSP) model describing Alzheimer's disease pathophysiology and treatment effects.
Journal: NPJ systems biology and applications
In common: Alzheimer's / dementia, 3 references
[9] doi:10.64898/2026.05.06.26352540 [code]
Generating synthetic tau-PET scans in Alzheimer’s disease from MRI, blood biomarkers and demographics with deep learning
Journal: medRxiv (preprint)
In common: Alzheimer's / dementia, 3 references
[10] doi:10.1007/s12035-026-06014-4
Hypothalamus Amyloid Levels Are Associated with Early Sex-Dependent Alterations in Peripheral Energy Homeostasis in TgF344-AD Rats.
Journal: Molecular neurobiology
In common: Alzheimer's / dementia, 3 references

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.