OSCR

<i>ADAMTS18</i> as a candidate gene linking social stress and depression: a cross-species study in African wild dogs (<i>Lycaon pictus</i>) and humans.

Code ↔ Paper

2 matches 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 2 matches
  1. [1] § Materials and methods › Processing of the sequencing data ↔ tools/loaders/bam-loader/bam-loader.c, lines 59–127 · score 0.67 · quality scores, mapping quality, Aligner, MAPQ, Duplicate, alignment
  2. [2] § Materials and methods › Processing of the sequencing data ↔ ngs/ngs-python/ngs/PileupEvent.py, lines 38–154 · score 0.57 · mapping quality, technology, deletions, insertions, INDELs, genomic

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

C · 1,388 lines · 43 KB · other · 1 match

  1. /*===========================================================================
  2. *
  3. * PUBLIC DOMAIN NOTICE
  4. * National Center for Biotechnology Information
  5. *
  6. * This software/database is a "United States Government Work" under the
  7. * terms of the United States Copyright Act. It was written as part of
  8. * the author's official duties as a United States Government employee and
  9. * thus cannot be copyrighted. This software/database is freely available
  10. * to the public for use. The National Library of Medicine and the U.S.
  11. * Government have not placed any restriction on its use or reproduction.
  12. *
  13. * Although all reasonable efforts have been taken to ensure the accuracy
  14. * and reliability of the software and data, the NLM and the U.S.
  15. * Government do not and cannot warrant the performance or results that
  16. * may be obtained by using this software or data. The NLM and the U.S.
  17. * Government disclaim all warranties, express or implied, including
  18. * warranties of performance, merchantability or fitness for any particular
  19. * purpose.
  20. *
  21. * Please cite the author in any work or product based on this material.
  22. *
  23. * ===========================================================================
  24. *
  25. */
  26. #include <stdlib.h>
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #include <kapp/main.h>
  31. #include <kapp/args.h>
  32. #include <klib/text.h>
  33. #include <klib/log.h>
  34. #include <klib/out.h>
  35. #include <klib/status.h>
  36. #include <klib/rc.h>
  37. #include <klib/printf.h>
  38. #include <kfs/directory.h>
  39. #include <kfs/file.h>
  40. #include <kapp/log-xml.h>
  41. #include <align/writer-refseq.h>
  42. #include <stdlib.h>
  43. #include <stdio.h>
  44. #include <string.h>
  45. #include <ctype.h>
  46. #include <assert.h>
  47. #include <limits.h>
  48. #include "Globals.h"
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #include "loader-imp.h"
  53. /*: ARGS
  54. Summary:
  55. Load a BAM formatted data file
  56. Usage:
  57. --help display this text and quit
  58. --version display the version string and quit
  59. [global-options] [options] <file...> [ --remap [options] <file>... ]...
  60. //:global-options
  61. Global Options:
  62. * options effecting logging
  63. log-level <level> logging level values: [fatal|sys|int|err|warn|info|0-5] default: info
  64. xml-log <filename> produce an XML-formatted log file
  65. * options effecting performance optimisation
  66. tmpfs <directory> where to store temparary files, default: '/tmp'
  67. cache-size <mbytes> the limit in MB for temparary files
  68. min-batch-size <number> minimum batch size for spot assembly (default 10e6)
  69. * options effecting error limits
  70. max-err-count <number> the maximum number of errors to ignore
  71. max-warning-dup-flag <count> the limit for number of duplicate flag mismatch warnings
  72. //:options
  73. Options:
  74. output <name> name of the output, required
  75. config <file> reference configuration file (See Configuration)
  76. header <file> file containing the SAM header
  77. remap special option to enable processing sets of remapped files. remap MUST be given between each set, all regular options can be respecified, in fact the output must be unique for each set. This is for when a set of reads are aligned multiple times, for example against different reference builds or with different aligners. This mode ensures that spot ids are the same across the several outputs.
  78. Debugging Options:
  79. only-verify exit after verifying existence of references
  80. max-rec-count <number> exit after processing this many records (per file)
  81. nomatch-log <path> log alignments with no matching bases
  82. Filtering Options:
  83. minimum-match <number> minimum number of matches for an alignment
  84. no-secondary ignore alignments marked as secondary
  85. accept-dups accept spots with inconsistent PCR duplicate flags
  86. accept-nomatch accept alignments with no matching bases
  87. ref-config limit processing to references in the config file, ignoring all others
  88. ref-filter <name> limit processing to the given reference, ignoring all others
  89. min-mapq <number> filter secondary alignments by minimum mapping quality
  90. Rare or Esoteric Options:
  91. input <directory> where to find fasta files
  92. ref-file <file> fasta file with references
  93. force-sorted disable sort-order checking
  94. unsorted expect unsorted input (requires more memory)
  95. sorted require sorted input
  96. TI look for trace id optional tag
  97. unaligned <file> file without aligned reads
  98. Deprecated Options:
  99. use-OQ use OQ option column for quality values instead of QUAL
  100. no-verify skip verify existence of references from the BAM file
  101. accept-hard-clip allow hard clipping in CIGAR
  102. allow-multi-map allow the same reference to be mapped to multiple names in the input files
  103. edit-aligned-qual <number> convert quality at aligned positions to this value
  104. cs turn on awareness of colorspace
  105. qual-quant quality scores quantization level
  106. keep-mismatch-qual don't quantized quality at mismatched positions
  107. Example:
  108. bam-load -o /tmp/SRZ123456 -k analysis.bam.cfg 123456.bam
  109. */
  110. /* MARK: Arguments and Usage */
  111. static char const option_input[] = "input";
  112. static char const option_output[] = "output";
  113. static char const option_tmpfs[] = "tmpfs";
  114. static char const option_config[] = "config";
  115. static char const option_min_mapq[] = "min-mapq";
  116. static char const option_qual_compress[] = "qual-quant";
  117. static char const option_cache_size[] = "cache-size";
  118. static char const option_no_sort_check[] = "force-sorted";
  119. static char const option_unsorted[] = "unsorted";
  120. static char const option_sorted[] = "sorted";
  121. static char const option_max_err_count[] = "max-err-count";
  122. static char const option_max_rec_count[] = "max-rec-count";
  123. static char const option_no_verify[] = "no-verify";
  124. static char const option_only_verify[] = "only-verify";
  125. static char const option_use_qual[] = "use-QUAL";
  126. static char const option_ref_filter[] = "ref-filter";
  127. static char const option_ref_config[] = "ref-config";
  128. static char const option_edit_aligned_qual[] = "edit-aligned-qual";
  129. static char const option_unaligned[] = "unaligned";
  130. static char const option_accept_dup[] = "accept-dups";
  131. static char const option_accept_nomatch[] = "accept-nomatch";
  132. static char const option_nomatch_log[] = "nomatch-log";
  133. static char const option_keep_mismatch_qual[] = "keep-mismatch-qual";
  134. static char const option_min_match[] = "minimum-match";
  135. static char const option_header[] = "header";
  136. static char const option_no_cs[] = "no-cs";
  137. static char const option_no_secondary[] = "no-secondary";
  138. static char const option_ref_file[] = "ref-file";
  139. static char const option_TI[] = "TI";
  140. static char const option_max_warn_dup_flag[] = "max-warning-dup-flag";
  141. static char const option_accept_hard_clip[] = "accept-hard-clip";
  142. static char const option_allow_multi_map[] = "allow-multi-map";
  143. static char const option_allow_secondary[] = "make-spots-with-secondary";
  144. static char const option_defer_secondary[] = "defer-secondary";
  145. static char const option_spot_batch_size[] = "batch-size";
  146. static char const option_threads[] = "threads";
  147. static char const option_extra_logging[] = "extra-logging";
  148. static char const option_min_batch_size[] = "min-batch-size";
  149. static char const option_telemetry[] = "telemetry";
  150. #define OPTION_INPUT option_input
  151. #define OPTION_OUTPUT option_output
  152. #define OPTION_TMPFS option_tmpfs
  153. #define OPTION_CONFIG option_config
  154. #define OPTION_MINMAPQ option_min_mapq
  155. #define OPTION_QCOMP option_qual_compress
  156. #define OPTION_CACHE_SIZE option_cache_size
  157. #define OPTION_MAX_ERR_COUNT option_max_err_count
  158. #define OPTION_MAX_REC_COUNT option_max_rec_count
  159. #define OPTION_UNALIGNED option_unaligned
  160. #define OPTION_ACCEPT_DUP option_accept_dup
  161. #define OPTION_ACCEPT_NOMATCH option_accept_nomatch
  162. #define OPTION_NOMATCH_LOG option_nomatch_log
  163. #define OPTION_MIN_MATCH option_min_match
  164. #define OPTION_HEADER option_header
  165. #define OPTION_NO_CS option_no_cs
  166. #define OPTION_NO_SECONDARY option_no_secondary
  167. #define OPTION_REF_FILE option_ref_file
  168. #define OPTION_TI option_TI
  169. #define OPTION_MAX_WARN_DUP_FLAG option_max_warn_dup_flag
  170. #define OPTION_ACCEPT_HARD_CLIP option_accept_hard_clip
  171. #define OPTION_ALLOW_MULTI_MAP option_allow_multi_map
  172. #define OPTION_ALLOW_SECONDARY option_allow_secondary
  173. #define OPTION_DEFER_SECONDARY option_defer_secondary
  174. #define OPTION_SPOT_BATCH_SIZE option_spot_batch_size
  175. #define OPTION_THREADS option_threads
  176. #define OPTION_EXTRA_LOGGING option_extra_logging
  177. #define OPTION_MIN_BATCH_SIZE option_min_batch_size
  178. #define OPTION_TELEMETRY option_telemetry
  179. #define ALIAS_INPUT "i"
  180. #define ALIAS_OUTPUT "o"
  181. #define ALIAS_TMPFS "t"
  182. #define ALIAS_CONFIG "k"
  183. #define ALIAS_MINMAPQ "q"
  184. #define ALIAS_QCOMP "Q"
  185. #define ALIAS_MAX_ERR_COUNT "E"
  186. #define ALIAS_UNALIGNED "u"
  187. #define ALIAS_ACCEPT_DUP "d"
  188. #define ALIAS_NO_SECONDARY "P"
  189. #define ALIAS_REF_FILE "r"
  190. static
  191. char const * input_usage[] =
  192. {
  193. "Path where to get fasta files from.",
  194. NULL
  195. };
  196. static
  197. char const * output_usage[] =
  198. {
  199. "Path and Name of the output database.",
  200. NULL
  201. };
  202. static
  203. char const * tmpfs_usage[] =
  204. {
  205. "Path to be used for scratch files.",
  206. NULL
  207. };
  208. static
  209. char const * config_usage[] =
  210. {
  211. "Path to configuration file:",
  212. "maps the input BAM file's reference names to the equivalent GenBank accession.",
  213. "It is a tab-delimited text file with unix line endings (\\n - LF) with the following fields in this order:",
  214. "#1 reference name as it occurs in the BAM file's SN field of @SQ header record;",
  215. "#2 INSDC reference ID",
  216. NULL
  217. };
  218. static
  219. char const * min_mapq_usage[] =
  220. {
  221. "Filter secondary alignments by minimum mapping quality.",
  222. NULL
  223. };
  224. static
  225. char const * qcomp_usage[] =
  226. {
  227. "Quality scores quantization level, can be a number (0: none, 1: 2bit, 2: 1bit), or a string like '1:10,10:20,20:30,30:-' (which is equivalent to 1) (nb. the endpoint is exclusive).",
  228. NULL
  229. };
  230. static
  231. char const * no_sort_usage[] =
  232. {
  233. "Disable sort order checking.",
  234. NULL
  235. };
  236. static
  237. char const * unsorted_usage[] =
  238. {
  239. "Tell the loader to expect unsorted input (requires more memory)",
  240. NULL
  241. };
  242. static
  243. char const * sorted_usage[] =
  244. {
  245. "Tell the loader to require sorted input",
  246. NULL
  247. };
  248. static
  249. char const * cache_size_usage[] =
  250. {
  251. "Set the cache size in MB for the temporary indices",
  252. NULL
  253. };
  254. static
  255. char const * mrc_usage[] =
  256. {
  257. "Set the maximum number of records to process from the BAM file",
  258. NULL
  259. };
  260. static
  261. char const * mec_usage[] =
  262. {
  263. "Set the maximum number of errors to ignore from the BAM file",
  264. NULL
  265. };
  266. static
  267. char const * no_verify_usage[] =
  268. {
  269. "Skip verify existence of references from the BAM file",
  270. NULL
  271. };
  272. static
  273. char const * only_verify_usage[] =
  274. {
  275. "Exit after verifying existence of references from the BAM file",
  276. NULL
  277. };
  278. static
  279. char const * use_QUAL_usage[] =
  280. {
  281. "use QUAL column for quality values (default is to use OQ if it is available)",
  282. NULL
  283. };
  284. static
  285. char const * use_ref_filter[] =
  286. {
  287. "Only process alignments to the given reference",
  288. NULL
  289. };
  290. static
  291. char const * use_ref_config[] =
  292. {
  293. "Only process alignments to references in the config file",
  294. NULL
  295. };
  296. static
  297. char const * use_edit_aligned_qual[] =
  298. {
  299. "Convert quality at aligned positions to this value",
  300. NULL
  301. };
  302. static
  303. char const * use_keep_mismatch_qual[] =
  304. {
  305. "Don't quantized quality at mismatched positions",
  306. NULL
  307. };
  308. static
  309. char const * use_unaligned[] =
  310. {
  311. "Specify file without aligned reads",
  312. NULL
  313. };
  314. static
  315. char const * use_accept_dups[] =
  316. {
  317. "Accept spots inconsistent PCR duplicate flags",
  318. NULL
  319. };
  320. static
  321. char const * use_accept_nomatch[] =
  322. {
  323. "Accept alignments with no matching bases",
  324. NULL
  325. };
  326. static
  327. char const * use_nomatch_log[] =
  328. {
  329. "Where to write info for alignments with no matching bases",
  330. NULL
  331. };
  332. static
  333. char const * use_min_match[] =
  334. {
  335. "minimum number of matches for an alignment",
  336. NULL
  337. };
  338. static
  339. char const * use_header[] =
  340. {
  341. "path to a file containing the SAM header to store in the resulting cSRA, recommended in case of multiple input BAMs",
  342. NULL
  343. };
  344. static
  345. char const * use_no_cs[] =
  346. {
  347. "turn off awareness of colorspace",
  348. NULL
  349. };
  350. static
  351. char const * use_no_secondary[] =
  352. {
  353. "ignore alignments marked as secondary",
  354. NULL
  355. };
  356. static
  357. char const * use_ref_file[] =
  358. {
  359. "path to a fasta file with references",
  360. NULL
  361. };
  362. static
  363. char const * use_TI[] =
  364. {
  365. "for trace alignments",
  366. NULL
  367. };
  368. static
  369. char const * use_max_dup_warnings[] =
  370. {
  371. "set limit for number of duplicate flag mismatch warnings",
  372. NULL
  373. };
  374. static
  375. char const * use_accept_hard_clip[] =
  376. {
  377. "accept hard clipping in CIGAR",
  378. NULL
  379. };
  380. static
  381. char const * use_allow_multi_map[] =
  382. {
  383. "allow the same reference to be mapped to multiple names in the input files",
  384. "(default is disallow, old behaviors was to allow it)",
  385. NULL
  386. };
  387. static
  388. char const * use_allow_secondary[] =
  389. {
  390. "use secondary alignments for constructing spots",
  391. NULL
  392. };
  393. static
  394. char const * use_defer_secondary[] =
  395. {
  396. "defer processing of secondary alignments until the end of the file",
  397. NULL
  398. };
  399. static
  400. char const * spot_batch_size[] =
  401. {
  402. "optional maximum size of the spot batches (default: 240e6)",
  403. NULL
  404. };
  405. static
  406. char const * number_of_threads[] =
  407. {
  408. "number of threads (3 or greater; can be 0, means default: 8)",
  409. NULL
  410. };
  411. static
  412. char const * is_extra_logging[] =
  413. {
  414. "extra_logging",
  415. NULL
  416. };
  417. static
  418. char const * min_batch_size_usage[] =
  419. {
  420. "Set the minimum batch size for spot assembly (default: 10,000,000 spots)",
  421. NULL
  422. };
  423. static
  424. char const * telemetry_usage[] =
  425. {
  426. "Path and Name of the telemetry file.",
  427. NULL
  428. };
  429. OptDef Options[] =
  430. {
  431. /* order here is same as in param array below!!! */
  432. { OPTION_INPUT, ALIAS_INPUT, NULL, input_usage, 1, true, false },
  433. { OPTION_OUTPUT, ALIAS_OUTPUT, NULL, output_usage, 1, true, true },
  434. { OPTION_CONFIG, ALIAS_CONFIG, NULL, config_usage, 1, true, false },
  435. { OPTION_HEADER, NULL, NULL, use_header, 1, true, false },
  436. { OPTION_TMPFS, ALIAS_TMPFS, NULL, tmpfs_usage, 1, true, false },
  437. { OPTION_UNALIGNED, ALIAS_UNALIGNED, NULL, use_unaligned, 256, true, false },
  438. { OPTION_ACCEPT_DUP, ALIAS_ACCEPT_DUP, NULL, use_accept_dups, 1, false, false },
  439. { OPTION_ACCEPT_NOMATCH, NULL, NULL, use_accept_nomatch, 1, false, false },
  440. { OPTION_NOMATCH_LOG, NULL, NULL, use_nomatch_log, 1, true, false },
  441. { OPTION_QCOMP, ALIAS_QCOMP, NULL, qcomp_usage, 1, true, false },
  442. { OPTION_MINMAPQ, ALIAS_MINMAPQ, NULL, min_mapq_usage, 1, true, false },
  443. { OPTION_CACHE_SIZE, NULL, NULL, cache_size_usage, 1, true, false },
  444. { OPTION_NO_CS, NULL, NULL, use_no_cs, 1, false, false },
  445. { OPTION_MIN_MATCH, NULL, NULL, use_min_match, 1, true, false },
  446. { OPTION_NO_SECONDARY, ALIAS_NO_SECONDARY, NULL, use_no_secondary, 1, false, false },
  447. { option_no_sort_check, NULL, NULL, no_sort_usage, 1, false, false },
  448. { option_unsorted, NULL, NULL, unsorted_usage, 1, false, false },
  449. { option_sorted, NULL, NULL, sorted_usage, 1, false, false },
  450. { option_no_verify, NULL, NULL, no_verify_usage, 1, false, false },
  451. { option_only_verify, NULL, NULL, only_verify_usage, 1, false, false },
  452. { option_use_qual, NULL, NULL, use_QUAL_usage, 1, false, false },
  453. { option_ref_config, NULL, NULL, use_ref_config, 1, false, false },
  454. { option_ref_filter, NULL, NULL, use_ref_filter, 1, true, false },
  455. { option_edit_aligned_qual, NULL, NULL, use_edit_aligned_qual, 1, true, false },
  456. { option_keep_mismatch_qual, NULL, NULL, use_keep_mismatch_qual, 1, false, false },
  457. { OPTION_MAX_REC_COUNT, NULL, NULL, mrc_usage, 1, true, false },
  458. { OPTION_MAX_ERR_COUNT, ALIAS_MAX_ERR_COUNT, NULL, mec_usage, 1, true, false },
  459. { OPTION_REF_FILE, ALIAS_REF_FILE, NULL, use_ref_file, 0, true, false },
  460. { OPTION_TI, NULL, NULL, use_TI, 1, false, false },
  461. { OPTION_MAX_WARN_DUP_FLAG, NULL, NULL, use_max_dup_warnings, 1, true, false },
  462. { OPTION_ACCEPT_HARD_CLIP, NULL, NULL, use_accept_hard_clip, 1, false, false },
  463. { OPTION_ALLOW_MULTI_MAP, NULL, NULL, use_allow_multi_map, 1, false, false },
  464. { OPTION_ALLOW_SECONDARY, NULL, NULL, use_allow_secondary, 1, false, false },
  465. { OPTION_DEFER_SECONDARY, NULL, NULL, use_defer_secondary, 1, false, false },
  466. { OPTION_SPOT_BATCH_SIZE, NULL, NULL, spot_batch_size, 1, true, false },
  467. { OPTION_THREADS, NULL, NULL, number_of_threads, 1, true, false },
  468. { OPTION_EXTRA_LOGGING, NULL, NULL, is_extra_logging, 1, false, false },
  469. { OPTION_MIN_BATCH_SIZE, NULL, NULL, min_batch_size_usage, 1, true, false },
  470. { OPTION_TELEMETRY, NULL, NULL, telemetry_usage, 1, true, false },
  471. };
  472. const char* OptHelpParam[] =
  473. {
  474. /* order here is same as in OptDef array above!!! */
  475. "path", /* input */
  476. "path", /* output */
  477. "path-to-file", /* config */
  478. "path-to-file", /* header */
  479. "path", /* tmpfs */
  480. "path-to-file", /* unaligned */
  481. NULL, /* accept dups */
  482. NULL, /* accept no-match */
  483. "path-to-file", /* no-match log */
  484. "level", /* quality compression */
  485. "phred-score", /* min. mapq */
  486. "mbytes", /* cache size */
  487. NULL, /* no colorspace */
  488. "count", /* min. match count */
  489. NULL, /* no secondary */
  490. NULL, /* no_sort */
  491. NULL, /* unsorted */
  492. NULL, /* sorted */
  493. NULL, /* no verify ref's */
  494. NULL, /* quit after verify ref's */
  495. NULL, /* force QUAL */
  496. NULL, /* ref's from config */
  497. "name", /* only this ref */
  498. "new-value", /* value for aligned qualities */
  499. NULL, /* no quantize mismatch qualities */
  500. "number", /* max. record count to process */
  501. "number", /* max. error count */
  502. "path-to-file", /* reference fasta file */
  503. NULL, /* use XT->TI */
  504. "count", /* max. duplicate warning count */
  505. NULL, /* allow hard clipping */
  506. NULL, /* allow multimapping */
  507. NULL, /* allow secondary */
  508. NULL, /* defer secondary */
  509. NULL, /* search batch size */
  510. NULL, /* threads */
  511. NULL, /* extra logging */
  512. "count", /* min cache size */
  513. "file-name" /* telemetry file name */
  514. };
  515. rc_t UsageSummary (char const * progname)
  516. {
  517. return KOutMsg (
  518. "Usage:\n"
  519. "\t%s [options] <bam-file>\n"
  520. "\n"
  521. "Summary:\n"
  522. "\tLoad a BAM formatted data file\n"
  523. "\n"
  524. "Example:\n"
  525. "\t%s -o /tmp/SRZ123456 -k analysis.bam.cfg 123456.bam\n"
  526. "\n"
  527. ,progname, progname);
  528. }
  529. char const UsageDefaultName[] = "bam-load";
  530. static const unsigned DEFAULT_BATCH_SIZE = 240e6;
  531. static const unsigned DEFAULT_MIN_SPOT_ASSEMPLY_BATCH_SIZE = 10e6;
  532. rc_t CC Usage (const Args * args)
  533. {
  534. rc_t rc;
  535. size_t i;
  536. const char * progname = UsageDefaultName;
  537. const char * fullpath = UsageDefaultName;
  538. const size_t argsQty = sizeof(Options) / sizeof(Options[0]);
  539. if (args == NULL)
  540. rc = RC (rcApp, rcArgv, rcAccessing, rcSelf, rcNull);
  541. else
  542. rc = ArgsProgram (args, &fullpath, &progname);
  543. if (rc)
  544. progname = fullpath = UsageDefaultName;
  545. UsageSummary (progname);
  546. for(i = 0; i < argsQty; i++ ) {
  547. if( Options[i].required && Options[i].help[0] != NULL ) {
  548. HelpOptionLine(Options[i].aliases, Options[i].name, OptHelpParam[i], Options[i].help);
  549. }
  550. }
  551. OUTMSG(("\nOptions:\n"));
  552. for(i = 0; i < argsQty; i++ ) {
  553. if( !Options[i].required && Options[i].help[0] != NULL ) {
  554. HelpOptionLine(Options[i].aliases, Options[i].name, OptHelpParam[i], Options[i].help);
  555. }
  556. }
  557. XMLLogger_Usage();
  558. OUTMSG(("\n"));
  559. HelpOptionsStandard ();
  560. HelpVersion (fullpath, KAppVersion());
  561. return rc;
  562. }
  563. /* MARK: Definitions and Globals */
  564. #define SCHEMAFILE "align/align.vschema"
  565. Globals G;
  566. #ifdef _WIN32
  567. #include <process.h>
  568. #else
  569. #include <unistd.h>
  570. #endif
  571. static void set_pid(void)
  572. {
  573. G.pid = getpid();
  574. }
  575. static rc_t PathWithBasePath(char rslt[], size_t sz, char const path[], char const base[])
  576. {
  577. size_t const plen = strlen(path);
  578. bool const hasBase = base && base[0];
  579. bool const isBareName = strchr(path, '/') == NULL;
  580. if (isBareName && hasBase) {
  581. if (string_printf(rslt, sz, NULL, "%s/%s", base, path) == 0)
  582. return 0;
  583. }
  584. else if (plen < sz) {
  585. strncpy(rslt, path, sz);
  586. return 0;
  587. }
  588. {
  589. rc_t const rc = RC(rcApp, rcArgv, rcAccessing, rcBuffer, rcInsufficient);
  590. (void)LOGERR(klogErr, rc, "The path to the file is too long");
  591. return rc;
  592. }
  593. }
  594. static rc_t OpenFile(KFile const **kf, char const path[], char const base[])
  595. {
  596. char fname[4096];
  597. rc_t rc = PathWithBasePath(fname, sizeof(fname), path, base);
  598. if (rc == 0) {
  599. KDirectory *dir;
  600. rc = KDirectoryNativeDir(&dir);
  601. if (rc == 0) {
  602. rc = KDirectoryOpenFileRead(dir, kf, "%s", fname);
  603. KDirectoryRelease(dir);
  604. }
  605. }
  606. return rc;
  607. }
  608. static rc_t LoadHeader(char const **rslt, char const path[], char const base[])
  609. {
  610. KFile const *kf;
  611. rc_t rc = OpenFile(&kf, path, base);
  612. *rslt = NULL;
  613. if (rc == 0) {
  614. uint64_t fsize;
  615. rc = KFileSize(kf, &fsize);
  616. if (rc == 0) {
  617. char *fdata = (char*)malloc(fsize+1);
  618. if (fdata) {
  619. size_t nread;
  620. rc = KFileRead(kf, 0, fdata, fsize, &nread);
  621. if (rc == 0) {
  622. if (nread) {
  623. fdata[nread] = '\0';
  624. *rslt = fdata;
  625. }
  626. else {
  627. free(fdata);
  628. rc = RC(rcApp, rcArgv, rcAccessing, rcFile, rcEmpty);
  629. (void)PLOGERR(klogErr, (klogErr, rc, "File '$(file)' is empty", "file=%s", path));
  630. }
  631. }
  632. else {
  633. (void)PLOGERR(klogErr, (klogErr, rc, "Failed to read file '$(file)'", "file=%s", path));
  634. }
  635. }
  636. else {
  637. rc = RC(rcApp, rcArgv, rcAccessing, rcMemory, rcExhausted);
  638. (void)PLOGERR(klogErr, (klogErr, rc, "Failed to read file '$(file)'", "file=%s", path));
  639. }
  640. }
  641. KFileRelease(kf);
  642. }
  643. else {
  644. (void)PLOGERR(klogErr, (klogErr, rc, "Failed to open file '$(file)'", "file=%s", path));
  645. }
  646. return rc;
  647. }
  648. static rc_t main_help_vers(int argc, char * argv[])
  649. {
  650. Args *args = NULL;
  651. rc_t const rc = ArgsMakeAndHandle (&args, argc, argv, 2, Options,
  652. sizeof Options / sizeof (OptDef), XMLLogger_Args, XMLLogger_ArgsQty);
  653. ArgsWhack(args);
  654. return rc;
  655. }
  656. static rc_t getArgValue(Args *const args, char const *name, int index, char const **result)
  657. {
  658. void const *value;
  659. rc_t const rc = ArgsOptionValue(args, name, index, &value);
  660. if (rc) return rc;
  661. free((void *)*result);
  662. *result = string_dup_measure((const char*)value, NULL);
  663. assert(*result);
  664. return 0;
  665. }
  666. static bool getFlag(Args *const args, char const *name, rc_t *rc)
  667. {
  668. uint32_t count = 0;
  669. *rc = ArgsOptionCount(args, name, &count);
  670. return *rc == 0 ? (count > 0) : false;
  671. }
  672. #define SET_FLAG(FLAG, OPTNAME) FLAG |= getFlag(args, OPTNAME, &rc); if (rc) break
  673. static rc_t main_1(int argc, char *argv[], bool const continuing, unsigned const load)
  674. {
  675. Args *args;
  676. rc_t rc;
  677. unsigned n_aligned = 0;
  678. unsigned n_unalgnd = 0;
  679. char *aligned[256];
  680. char *unalgnd[256];
  681. char *name_buffer = NULL;
  682. unsigned next_name = 0;
  683. unsigned nbsz = 0;
  684. char const *value;
  685. char *dummy;
  686. rc = ArgsMakeAndHandle (&args, argc, argv, 1, Options, sizeof(Options)/sizeof(Options[0]));
  687. while (rc == 0) {
  688. uint32_t pcount;
  689. SET_FLAG(G.onlyVerifyReferences, option_only_verify);
  690. SET_FLAG(G.noVerifyReferences, option_no_verify);
  691. SET_FLAG(G.useQUAL, option_use_qual);
  692. SET_FLAG(G.limit2config, option_ref_config);
  693. SET_FLAG(G.noSortOrderCheck, option_no_sort_check);
  694. SET_FLAG(G.expectUnsorted, option_unsorted);
  695. SET_FLAG(G.requireSorted, option_sorted);
  696. SET_FLAG(G.acceptBadDups, OPTION_ACCEPT_DUP);
  697. SET_FLAG(G.acceptNoMatch, OPTION_ACCEPT_NOMATCH);
  698. SET_FLAG(G.keepMismatchQual, option_keep_mismatch_qual);
  699. SET_FLAG(G.noColorSpace, OPTION_NO_CS);
  700. SET_FLAG(G.noSecondary, OPTION_NO_SECONDARY);
  701. SET_FLAG(G.hasTI, OPTION_TI);
  702. SET_FLAG(G.acceptHardClip, OPTION_ACCEPT_HARD_CLIP);
  703. SET_FLAG(G.allowMultiMapping, OPTION_ALLOW_MULTI_MAP);
  704. SET_FLAG(G.assembleWithSecondary, OPTION_ALLOW_SECONDARY);
  705. SET_FLAG(G.deferSecondary, OPTION_DEFER_SECONDARY);
  706. SET_FLAG(G.hasExtraLogging, OPTION_EXTRA_LOGGING);
  707. rc = ArgsOptionCount(args, OPTION_REF_FILE, &pcount);
  708. if (rc)
  709. break;
  710. if (pcount && G.refFiles) {
  711. int i;
  712. for (i = 0; G.refFiles[i]; ++i)
  713. free((void *)G.refFiles[i]);
  714. free((void *)G.refFiles);
  715. }
  716. G.refFiles = (const char**)calloc(pcount + 1, sizeof(*(G.refFiles)));
  717. if (!G.refFiles) {
  718. rc = RC(rcApp, rcArgv, rcAccessing, rcMemory, rcExhausted);
  719. break;
  720. }
  721. while(pcount-- > 0) {
  722. rc = getArgValue(args, OPTION_REF_FILE, pcount, &G.refFiles[pcount]);
  723. if (rc)
  724. break;
  725. }
  726. rc = ArgsOptionCount (args, OPTION_TMPFS, &pcount);
  727. if (rc)
  728. break;
  729. if (pcount == 1)
  730. {
  731. rc = getArgValue(args, OPTION_TMPFS, 0, &G.tmpfs);
  732. if (rc)
  733. break;
  734. }
  735. else if (pcount > 1)
  736. {
  737. rc = RC(rcApp, rcArgv, rcAccessing, rcParam, rcExcessive);
  738. OUTMSG (("Single parameter required\n"));
  739. MiniUsage (args);
  740. break;
  741. }
  742. rc = ArgsOptionCount (args, OPTION_INPUT, &pcount);
  743. if (rc)
  744. break;
  745. if (pcount == 1)
  746. {
  747. rc = getArgValue(args, OPTION_INPUT, 0, &G.inpath);
  748. if (rc)
  749. break;
  750. }
  751. else if (pcount > 1)
  752. {
  753. rc = RC(rcApp, rcArgv, rcAccessing, rcParam, rcExcessive);
  754. OUTMSG (("Single input parameter required\n"));
  755. MiniUsage (args);
  756. break;
  757. }
  758. rc = ArgsOptionCount (args, option_ref_filter, &pcount);
  759. if (rc)
  760. break;
  761. if (pcount == 1)
  762. {
  763. rc = getArgValue(args, option_ref_filter, 0, &G.refFilter);
  764. if (rc)
  765. break;
  766. }
  767. else if (pcount > 1)
  768. {
  769. rc = RC(rcApp, rcArgv, rcAccessing, rcParam, rcExcessive);
  770. OUTMSG (("Single parameter required\n"));
  771. MiniUsage (args);
  772. break;
  773. }
  774. rc = ArgsOptionCount (args, OPTION_CONFIG, &pcount);
  775. if (rc)
  776. break;
  777. if (pcount == 1)
  778. {
  779. rc = getArgValue(args, OPTION_CONFIG, 0, &G.refXRefPath);
  780. if (rc)
  781. break;
  782. }
  783. else if (pcount > 1)
  784. {
  785. rc = RC(rcApp, rcArgv, rcAccessing, rcParam, rcExcessive);
  786. OUTMSG (("Single input parameter required\n"));
  787. MiniUsage (args);
  788. break;
  789. }
  790. rc = ArgsOptionCount (args, OPTION_OUTPUT, &pcount);
  791. if (rc)
  792. break;
  793. if (pcount == 1)
  794. {
  795. rc = getArgValue(args, OPTION_OUTPUT, 0, &G.outpath);
  796. if (rc)
  797. break;
  798. if (load == 0) {
  799. G.firstOut = string_dup_measure(G.outpath, NULL);
  800. }
  801. value = strrchr(G.outpath, '/');
  802. G.outname = value ? (value + 1) : G.outpath;
  803. }
  804. else if (pcount > 1)
  805. {
  806. rc = RC(rcApp, rcArgv, rcAccessing, rcParam, rcExcessive);
  807. OUTMSG (("Single output parameter required\n"));
  808. MiniUsage (args);
  809. break;
  810. }
  811. else if (!G.onlyVerifyReferences) {
  812. rc = RC(rcApp, rcArgv, rcAccessing, rcParam, rcInsufficient);
  813. OUTMSG (("Output parameter required\n"));
  814. MiniUsage (args);
  815. break;
  816. }
  817. rc = ArgsOptionCount (args, OPTION_MINMAPQ, &pcount);
  818. if (rc)
  819. break;
  820. if (pcount == 1)
  821. {
  822. rc = ArgsOptionValue(args, OPTION_MINMAPQ, 0, (const void **)&value);
  823. if (rc)
  824. break;
  825. G.minMapQual = strtoul(value, &dummy, 0);
  826. }
  827. rc = ArgsOptionCount (args, OPTION_QCOMP, &pcount);
  828. if (rc)
  829. break;
  830. if (pcount == 1)
  831. {
  832. rc = getArgValue(args, OPTION_QCOMP, 0, &G.QualQuantizer);
  833. if (rc)
  834. break;
  835. }
  836. rc = ArgsOptionCount (args, option_edit_aligned_qual, &pcount);
  837. if (rc)
  838. break;
  839. if (pcount == 1)
  840. {
  841. rc = ArgsOptionValue (args, option_edit_aligned_qual, 0, (const void **)&value);
  842. if (rc)
  843. break;
  844. G.alignedQualValue = strtoul(value, &dummy, 0);
  845. if (G.alignedQualValue == 0) {
  846. rc = RC(rcApp, rcArgv, rcAccessing, rcParam, rcIncorrect);
  847. OUTMSG (("edit-aligned-qual: bad value\n"));
  848. MiniUsage (args);
  849. break;
  850. }
  851. G.editAlignedQual = true;
  852. }
  853. rc = ArgsOptionCount (args, OPTION_CACHE_SIZE, &pcount);
  854. if (rc)
  855. break;
  856. if (pcount == 1)
  857. {
  858. rc = ArgsOptionValue (args, OPTION_CACHE_SIZE, 0, (const void **)&value);
  859. if (rc)
  860. break;
  861. G.cache_size = strtoul(value, &dummy, 0) * 1024UL * 1024UL;
  862. if (G.cache_size == 0) {
  863. rc = RC(rcApp, rcArgv, rcAccessing, rcParam, rcIncorrect);
  864. OUTMSG (("cache-size: bad value\n"));
  865. MiniUsage (args);
  866. break;
  867. }
  868. }
  869. rc = ArgsOptionCount (args, OPTION_MAX_WARN_DUP_FLAG, &pcount);
  870. if (rc)
  871. break;
  872. if (pcount == 1)
  873. {
  874. rc = ArgsOptionValue (args, OPTION_MAX_WARN_DUP_FLAG, 0, (const void **)&value);
  875. if (rc)
  876. break;
  877. G.maxWarnCount_DupConflict = strtoul(value, &dummy, 0);
  878. }
  879. rc = ArgsOptionCount (args, OPTION_MAX_REC_COUNT, &pcount);
  880. if (rc)
  881. break;
  882. if (pcount == 1)
  883. {
  884. rc = ArgsOptionValue (args, OPTION_MAX_REC_COUNT, 0, (const void **)&value);
  885. if (rc)
  886. break;
  887. G.maxAlignCount = strtoul(value, &dummy, 0);
  888. }
  889. rc = ArgsOptionCount (args, OPTION_MAX_ERR_COUNT, &pcount);
  890. if (rc)
  891. break;
  892. if (pcount == 1)
  893. {
  894. rc = ArgsOptionValue (args, OPTION_MAX_ERR_COUNT, 0, (const void **)&value);
  895. if (rc)
  896. break;
  897. G.maxErrCount = strtoul(value, &dummy, 0);
  898. }
  899. rc = ArgsOptionCount (args, OPTION_MIN_MATCH, &pcount);
  900. if (rc)
  901. break;
  902. if (pcount == 1)
  903. {
  904. rc = ArgsOptionValue (args, OPTION_MIN_MATCH, 0, (const void **)&value);
  905. if (rc)
  906. break;
  907. G.minMatchCount = strtoul(value, &dummy, 0);
  908. }
  909. rc = ArgsOptionCount (args, OPTION_NOMATCH_LOG, &pcount);
  910. if (rc)
  911. break;
  912. if (pcount == 1)
  913. {
  914. KDirectory *dir;
  915. rc = ArgsOptionValue (args, OPTION_NOMATCH_LOG, 0, (const void **)&value);
  916. if (rc) break;
  917. rc = KDirectoryNativeDir(&dir);
  918. if (rc) break;
  919. rc = KDirectoryCreateFile(dir, &G.noMatchLog, 0, 0664, kcmInit, "%s", value);
  920. KDirectoryRelease(dir);
  921. if (rc) break;
  922. }
  923. rc = ArgsOptionCount (args, OPTION_HEADER, &pcount);
  924. if (rc)
  925. break;
  926. if (pcount == 1) {
  927. rc = ArgsOptionValue (args, OPTION_HEADER, 0, (const void **)&value);
  928. if (rc) break;
  929. free((void *)G.headerText);
  930. rc = LoadHeader(&G.headerText, value, G.inpath);
  931. if (rc) break;
  932. }
  933. rc = ArgsParamCount (args, &pcount);
  934. if (rc) break;
  935. if (pcount == 0)
  936. {
  937. rc = RC(rcApp, rcArgv, rcAccessing, rcParam, rcInsufficient);
  938. MiniUsage (args);
  939. break;
  940. }
  941. else if (pcount > sizeof(aligned)/sizeof(aligned[0])) {
  942. rc = RC(rcApp, rcArgv, rcAccessing, rcParam, rcExcessive);
  943. (void)PLOGERR(klogErr, (klogErr, rc, "$(count) input files is too many, $(max) is the limit",
  944. "count=%u,max=%u", (unsigned)pcount, (unsigned)(sizeof(aligned)/sizeof(aligned[0]))));
  945. break;
  946. }
  947. else {
  948. unsigned need = G.inpath ? (strlen(G.inpath) + 1) * pcount : 0;
  949. unsigned i;
  950. for (i = 0; i < pcount; ++i) {
  951. rc = ArgsParamValue(args, i, (const void **)&value);
  952. if (rc) break;
  953. need += strlen(value) + 1;
  954. }
  955. nbsz = need;
  956. }
  957. rc = ArgsOptionCount (args, OPTION_UNALIGNED, &pcount);
  958. if (rc)
  959. break;
  960. if (pcount > 0)
  961. {
  962. unsigned need = G.inpath ? (strlen(G.inpath) + 1) * pcount : 0;
  963. unsigned i;
  964. for (i = 0; i < pcount; ++i) {
  965. rc = ArgsOptionValue(args, OPTION_UNALIGNED, i, (const void **)&value);
  966. if (rc) break;
  967. need += strlen(value) + 1;
  968. }
  969. if (rc) break;
  970. nbsz += need;
  971. }
  972. name_buffer = (char*)malloc(nbsz);
  973. if (name_buffer == NULL) {
  974. rc = RC(rcApp, rcArgv, rcAccessing, rcMemory, rcExhausted);
  975. break;
  976. }
  977. rc = ArgsOptionCount (args, OPTION_UNALIGNED, &pcount);
  978. if (rc == 0) {
  979. unsigned i;
  980. for (i = 0; i < pcount; ++i) {
  981. rc = ArgsOptionValue(args, OPTION_UNALIGNED, i, (const void **)&value);
  982. if (rc) break;
  983. unalgnd[n_unalgnd++] = name_buffer + next_name;
  984. rc = PathWithBasePath(name_buffer + next_name, nbsz - next_name, value, G.inpath);
  985. if (rc) break;
  986. next_name += strlen(name_buffer + next_name) + 1;
  987. }
  988. if (rc) break;
  989. }
  990. else
  991. break;
  992. rc = ArgsParamCount (args, &pcount);
  993. if (rc == 0) {
  994. unsigned i;
  995. for (i = 0; i < pcount; ++i) {
  996. rc = ArgsParamValue(args, i, (const void **)&value);
  997. if (rc) break;
  998. aligned[n_aligned++] = name_buffer + next_name;
  999. rc = PathWithBasePath(name_buffer + next_name, nbsz - next_name, value, G.inpath);
  1000. if (rc) break;
  1001. next_name += strlen(name_buffer + next_name) + 1;
  1002. }
  1003. }
  1004. else
  1005. break;
  1006. rc = ArgsOptionCount (args, OPTION_SPOT_BATCH_SIZE, &pcount);
  1007. if (rc)
  1008. break;
  1009. if (pcount == 1)
  1010. {
  1011. rc = ArgsOptionValue (args, OPTION_SPOT_BATCH_SIZE, 0, (const void **)&value);
  1012. if (rc)
  1013. break;
  1014. G.searchBatchSize = strtoul(value, &dummy, 0);
  1015. if (G.searchBatchSize == 0)
  1016. G.searchBatchSize = DEFAULT_BATCH_SIZE;
  1017. }
  1018. rc = ArgsOptionCount (args, OPTION_THREADS, &pcount);
  1019. if (rc)
  1020. break;
  1021. if (pcount == 1)
  1022. {
  1023. rc = ArgsOptionValue (args, OPTION_THREADS, 0, (const void **)&value);
  1024. if (rc)
  1025. break;
  1026. char* p;
  1027. G.numThreads = strtoul(value, &p, 0);
  1028. if ( * p != 0 || ( G.numThreads < 3 && G.numThreads != 0 ) )
  1029. {
  1030. rc = RC(rcApp, rcArgv, rcAccessing, rcParam, rcIncorrect);
  1031. OUTMSG (("threads: bad value (must be an integer >=3, or 0)\n"));
  1032. MiniUsage (args);
  1033. break;
  1034. }
  1035. if (G.numThreads == 0)
  1036. G.numThreads = 8;
  1037. }
  1038. rc = ArgsOptionCount (args, OPTION_MIN_BATCH_SIZE, &pcount);
  1039. if (rc)
  1040. break;
  1041. if (pcount == 1)
  1042. {
  1043. rc = ArgsOptionValue (args, OPTION_MIN_BATCH_SIZE, 0, (const void **)&value);
  1044. if (rc)
  1045. break;
  1046. G.minBatchSize = strtoul(value, &dummy, 0);
  1047. if (G.minBatchSize == 0) {
  1048. rc = RC(rcApp, rcArgv, rcAccessing, rcParam, rcIncorrect);
  1049. OUTMSG (("min-batch-size: bad value\n"));
  1050. MiniUsage (args);
  1051. break;
  1052. }
  1053. }
  1054. G.telemetryPath = nullptr;
  1055. rc = ArgsOptionCount (args, OPTION_TELEMETRY, &pcount);
  1056. if (rc)
  1057. break;
  1058. if (pcount == 1)
  1059. {
  1060. rc = getArgValue(args, OPTION_TELEMETRY, 0, &G.telemetryPath);
  1061. if (rc)
  1062. break;
  1063. }
  1064. else if (pcount > 1)
  1065. {
  1066. rc = RC(rcApp, rcArgv, rcAccessing, rcParam, rcExcessive);
  1067. OUTMSG (("Single input parameter required\n"));
  1068. MiniUsage (args);
  1069. break;
  1070. }
  1071. rc = run(argv[0], n_aligned, (char const **)aligned, n_unalgnd, (char const **)unalgnd, continuing);
  1072. break;
  1073. }
  1074. free(name_buffer);
  1075. if (rc) {
  1076. (void)PLOGERR(klogErr, (klogErr, rc, "load failed",
  1077. "severity=total,status=failure,accession=%s,errors=%u", G.outname, G.errCount));
  1078. } else {
  1079. (void)PLOGMSG(klogInfo, (klogInfo, "loaded",
  1080. "severity=total,status=success,accession=%s,errors=%u", G.outname, G.errCount));
  1081. }
  1082. ArgsWhack(args);
  1083. return rc;
  1084. }
  1085. #undef SET_FLAG
  1086. static void cleanupGlobal(void)
  1087. {
  1088. if (G.refFiles) {
  1089. int i;
  1090. for (i = 0; G.refFiles[i]; ++i)
  1091. free((void *)G.refFiles[i]);
  1092. free((void *)G.refFiles);
  1093. }
  1094. free((void *)G.tmpfs);
  1095. free((void *)G.inpath);
  1096. free((void *)G.refFilter);
  1097. free((void *)G.refXRefPath);
  1098. free((void *)G.outpath);
  1099. free((void *)G.firstOut);
  1100. free((void *)G.headerText);
  1101. free((void *)G.QualQuantizer);
  1102. free((void *)G.schemaPath);
  1103. free((void *)G.telemetryPath);
  1104. }
  1105. static int find_arg(char const *const *const query, int const first, int const argc, char **const argv)
  1106. {
  1107. int i;
  1108. for (i = first; i < argc; ++i) {
  1109. int j;
  1110. for (j = 0; query[j] != NULL; ++j) {
  1111. if (strcmp(argv[i], query[j]) == 0)
  1112. return i;
  1113. }
  1114. }
  1115. return 0;
  1116. }
  1117. static bool has_arg(char const *const *const query, int const argc, char **const argv)
  1118. {
  1119. return find_arg(query, 1, argc, argv) > 0;
  1120. }
  1121. static const char *logger_options[] = { "--xml-log-fd", "--xml-log", "-z" };
  1122. static XMLLogger const *make_logger(int *argc, char *argv[])
  1123. {
  1124. XMLLogger const *rslt = NULL;
  1125. char *argf[4];
  1126. int i;
  1127. argf[0] = argv[0];
  1128. argf[1] = NULL;
  1129. argf[2] = NULL;
  1130. argf[3] = NULL;
  1131. for (i = 1; i < *argc; ++i) {
  1132. int remove = 0;
  1133. if (strcmp(argv[i], logger_options[2]) == 0) {
  1134. argf[1] = argv[i];
  1135. argf[2] = argv[i + 1];
  1136. remove = 2;
  1137. }
  1138. else {
  1139. int j;
  1140. for (j = 0; j < 2; ++j) {
  1141. if (strstr(argv[i], logger_options[j]) == argv[i]) {
  1142. int const n = strlen(logger_options[j]);
  1143. if (argv[i][n] == '\0') {
  1144. argf[1] = argv[i];
  1145. argf[2] = argv[i + 1];
  1146. remove = 2;
  1147. }
  1148. else if (argv[i][n] == '=') {
  1149. argv[i][n] = '\0';
  1150. argf[1] = argv[i];
  1151. argf[2] = argv[i] + n + 1;
  1152. remove = 1;
  1153. }
  1154. break;
  1155. }
  1156. }
  1157. }
  1158. if (argf[1] != NULL) {
  1159. Args *args = NULL;
  1160. ArgsMakeAndHandle(&args, 3, argf, 1, XMLLogger_Args, XMLLogger_ArgsQty);
  1161. if (args) {
  1162. XMLLogger_Make(&rslt, NULL, args);
  1163. ArgsWhack(args);
  1164. }
  1165. }
  1166. if (remove) {
  1167. *argc -= remove;
  1168. memmove(argv + i, argv + i + remove, (*argc + 1) * sizeof(argv[0]));
  1169. break;
  1170. }
  1171. }
  1172. return rslt;
  1173. }
  1174. MAIN_DECL( argc, argv )
  1175. {
  1176. if ( VdbInitialize( argc, argv, 0 ) )
  1177. return VDB_INIT_FAILED;
  1178. static const char *help[] = { "--help", "-h", "-?", NULL };
  1179. static const char *vers[] = { "--version", "-V", NULL };
  1180. SetUsage( Usage );
  1181. SetUsageSummary( UsageSummary );
  1182. bool const has_help = has_arg(help, argc, argv);
  1183. bool const has_vers = has_arg(vers, argc, argv);
  1184. XMLLogger const *logger = NULL;
  1185. int argfirst = 0;
  1186. int arglast = 0;
  1187. rc_t rc = 0;
  1188. unsigned load = 0;
  1189. assert(sizeof Options / sizeof Options[0] ==
  1190. sizeof OptHelpParam / sizeof OptHelpParam[0]
  1191. && "Options & OptHelpParam have to match");
  1192. if (has_help) {
  1193. argc = 2;
  1194. argv[1] = (char*)"--help";
  1195. return main_help_vers(argc, argv);
  1196. }
  1197. if (has_vers) {
  1198. argc = 2;
  1199. argv[1] = (char*)"--version";
  1200. return main_help_vers(argc, argv);
  1201. }
  1202. logger = make_logger(&argc, argv);
  1203. memset(&G, 0, sizeof(G));
  1204. G.mode = mode_Archive;
  1205. G.globalMode = mode_Archive;
  1206. G.maxSeqLen = TableWriterRefSeq_MAX_SEQ_LEN;
  1207. G.schemaPath = string_dup_measure(SCHEMAFILE, NULL);
  1208. G.omit_aligned_reads = true;
  1209. G.omit_reference_reads = true;
  1210. G.minMapQual = 0; /* accept all */
  1211. G.tmpfs = string_dup_measure("/tmp", NULL);
  1212. G.cache_size = ((size_t)16) << 30;
  1213. G.maxErrCount = 1000;
  1214. G.minMatchCount = 10;
  1215. G.searchBatchSize = DEFAULT_BATCH_SIZE;
  1216. G.numThreads = 8;
  1217. G.minBatchSize = DEFAULT_MIN_SPOT_ASSEMPLY_BATCH_SIZE;
  1218. if (char* env = getenv("LOADER_MEM_LIMIT_GB")) {
  1219. G.LOADER_MEM_LIMIT_GB = atoi(env);
  1220. (void)PLOGMSG(klogInfo, (klogInfo, "LOADER_MEM_LIMIT_GB=$(cnt)", "cnt=%u", G.LOADER_MEM_LIMIT_GB));
  1221. } else {
  1222. G.LOADER_MEM_LIMIT_GB = 0;
  1223. }
  1224. set_pid();
  1225. for (arglast = 1; arglast < argc; ++arglast) {
  1226. if (strcmp(argv[arglast], "--remap") == 0) {
  1227. argv[arglast] = argv[0];
  1228. G.globalMode = mode_Remap;
  1229. rc = main_1(arglast - argfirst, argv + argfirst, true, load);
  1230. if (rc)
  1231. break;
  1232. G.mode = mode_Remap;
  1233. argfirst = arglast;
  1234. ++load;
  1235. }
  1236. }
  1237. rc = main_1(arglast - argfirst, argv + argfirst, false, load);
  1238. XMLLogger_Release(logger);
  1239. cleanupGlobal();
  1240. return VdbTerminate( rc );
  1241. }

bam-loader.c at commit 434ae78, under other · at the source

Overview

Authors: Jihoon Park1, Jin-Gwan Jeon2, Youbin Kang3, Kyu-Man Han1, Daun Shin4, Mi-Ryung Han2,5, Byung-Joo Ham1
ORCID iDs: Byung-Joo Ham
  1. Department of Psychiatry, Korea University Anam Hospital, Korea University College of Medicine, Seoul, Republic of Korea
  2. Division of Life Sciences, College of Life Sciences and Bioengineering, Incheon National University, Incheon, Republic of Korea
  3. Department of Biomedical Sciences, Korea University College of Medicine, Seoul, Republic of Korea
  4. Department of Psychiatry, Asan Medical Center, Seoul, Republic of Korea
  5. Institute for New Drug Development, College of Life Science and Bioengineering, Incheon National University, Incheon, Republic of Korea
Institutions: Korea University Anam Hospital (South Korea); Incheon National University (South Korea); Korea University (South Korea); Asan Medical Center (South Korea)
Journal: Frontiers in behavioral neuroscience, volume 20, article 1878769
Dates: received 12 May 2026; accepted 8 July 2026; published online 29 July 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.3389/fnbeh.2026.1878769 · PMID 42591615 · PMCID PMC13462048 · OpenAlex W7171700345
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: genetics / omics (modality), structural MRI / diffusion (modality), human (organism), other (organism), depression (population), cellular / molecular (subfield)
Methods: Statistics, Smoothing, state filtering, decompositions, fMRI & imaging
Keywords: ADAMTS18, cross-species genomics, diffusion tensor imaging, Lycaon pictus, major depressive disorder, neuroimaging genetics, white matter connectivity
Topic: Human-Animal Interaction Studies (Genetics, Biochemistry, Genetics and Molecular Biology), according to OpenAlex
Citations: not cited yet (Europe PMC); 90 references in the paper

Abstract

Background: Major depressive disorder (MDD) is a leading cause of disability; however, its neurogenetic mechanisms remain partially understood. Comparative genomic approaches reveal evolutionarily conserved risk factors, particularly when applied to ecologically valid models. Lycaon pictus is a social carnivore whose affiliative behavior has been shaped by natural selection. Since impaired social and affiliative function are a feature of depression, genes selected for social function in this species may serve as candidates for the social-affective dimension of MDD. Here, a comparative approach was integrated with human neuroimaging–genetic analysis, focusing on white matter phenotypes.

Methods: Whole-genome sequencing data from Lycaon pictus (n = 7) and Canis lupus (n = 36) were analyzed alongside a human cohort of 367 patients with MDD and 161 healthy controls using rare variant association tests. Across analyses, ADAMTS18 emerged as a convergent gene of interest. Whole-exome sequencing and diffusion tensor imaging (DTI) were conducted on 234 patients with MDD and 135 healthy controls. Eleven common SNPs within ADAMTS18 were examined for genotype-by-diagnosis and genotype-by-symptom interactions using tract-based DTI metrics.

Results: SNP rs11643211 showed a nominal genotype × diagnosis interaction on axial diffusivity in the bilateral uncinate fasciculus, with elevated values in A allele carriers with MDD. In symptom-based models, rs1948719 was nominally associated with depression severity in the left cingulum–cingulate gyrus. Although these associations did not survive false discovery rate correction, the nominal effects appeared to cluster within tracts implicated in affective integration and self-referential cognition.

Conclusion: The present study is hypothesis-generating and identifies ADAMTS18 as a gene worth further study in relation to white matter and depression. Cross-species neurogenomics may offer a useful framework for investigating links among social behavior, genetic variation and psychiatric vulnerability. However, given the small sample sizes and the absence of FDR-significant results, these findings should be interpreted as providing an exploratory framework for identifying candidate markers relevant to MDD.

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 2 matches between paragraphs and lines of code.

ncbi/sra-tools

License: other
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 434ae787c86e32e7faa5e80417a342c365fa03b0, 25 March 2026
Languages: C/C++ (605), C (422), C++ (287), Shell (189), Java (74), Python (69), Perl (40)
Size: 3,759 files, 1,686 scripts
Software Heritage: archived
Found in: the text, “Processing of the sequencing data”
Holds: README, license file, environment (build/docker/Dockerfile, build/docker/Dockerfile.build-alpine, build/docker/Dockerfile.build-alpine-debug, build/docker/Dockerfile.build-amazonlinux, build/docker/Dockerfile.build-ubuntu, build/docker/Dockerfile.build_with_loaders-alpine, build/docker/Dockerfile.delite, ngs/ngs-python/setup.py), tests
Not found: CITATION.cff, continuous integration, documentation
Tools: h5py (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
1,652 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;
  • 1,650 scripts, each with its path and the digest of its content;
  • 2 matches 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

The datasets presented in this study can be found in online repositories. The names of the repositories and accession numbers can be found in the article/Supplementary material. Human genetic and neuroimaging datasets generated and analyzed during the current study are available from the corresponding author upon reasonable request and subject to institutional ethical and privacy restrictions.

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 2, 28 September 2026

  • Funding: added National Research Foundation; Incheon National University; National Research Foundation of Korea: NRF-2022R1A2C2093009, 2022R1A2C2093009; Ministry of Science and ICT, South Korea: NRF-2022R1A2C2093009

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, pages, dates, 7 authors, 7 keywords, 86 references.

Cite

This paper

Park, J., Jeon, J.-G., Kang, Y., Han, K.-M., Shin, D., Han, M.-R., & Ham, B.-J. (2026). &lt;i&gt;ADAMTS18&lt;/i&gt; as a candidate gene linking social stress and depression: a cross-species study in African wild dogs (&lt;i&gt;Lycaon pictus&lt;/i&gt;) and humans. Frontiers in behavioral neuroscience, 20, 1878769. https://doi.org/10.3389/fnbeh.2026.1878769

BibTeX

@article{park2026lt,
author = {Park, Jihoon and Jeon, Jin-Gwan and Kang, Youbin and Han, Kyu-Man and Shin, Daun and Han, Mi-Ryung and Ham, Byung-Joo},
title = {{\&lt;i\&gt;ADAMTS18\&lt;/i\&gt; as a candidate gene linking social stress and depression: a cross-species study in African wild dogs (\&lt;i\&gt;Lycaon pictus\&lt;/i\&gt;) and humans}},
journal = {Frontiers in behavioral neuroscience},
year = {2026},
month = jul,
volume = {20},
pages = {1878769},
publisher = {Frontiers Media SA},
issn = {1662-5153},
doi = {10.3389/fnbeh.2026.1878769},
url = {https://doi.org/10.3389/fnbeh.2026.1878769},
pmid = {42591615},
pmcid = {PMC13462048}
}

RIS

TY - JOUR
AU - Park, Jihoon
AU - Jeon, Jin-Gwan
AU - Kang, Youbin
AU - Han, Kyu-Man
AU - Shin, Daun
AU - Han, Mi-Ryung
AU - Ham, Byung-Joo
TI - &lt;i&gt;ADAMTS18&lt;/i&gt; as a candidate gene linking social stress and depression: a cross-species study in African wild dogs (&lt;i&gt;Lycaon pictus&lt;/i&gt;) and humans
T2 - Frontiers in behavioral neuroscience
J2 - Front Behav Neurosci
PY - 2026
DA - 2026/07/29
VL - 20
SP - 1878769
SN - 1662-5153
PB - Frontiers Media SA
DO - 10.3389/fnbeh.2026.1878769
UR - https://doi.org/10.3389/fnbeh.2026.1878769
LA - en
ER -

CSL-JSON

{
"id": "10.3389/fnbeh.2026.1878769",
"type": "article-journal",
"title": "&lt;i&gt;ADAMTS18&lt;/i&gt; as a candidate gene linking social stress and depression: a cross-species study in African wild dogs (&lt;i&gt;Lycaon pictus&lt;/i&gt;) and humans",
"container-title": "Frontiers in behavioral neuroscience",
"author": [
{
"family": "Park",
"given": "Jihoon"
},
{
"family": "Jeon",
"given": "Jin-Gwan"
},
{
"family": "Kang",
"given": "Youbin"
},
{
"family": "Han",
"given": "Kyu-Man"
},
{
"family": "Shin",
"given": "Daun"
},
{
"family": "Han",
"given": "Mi-Ryung"
},
{
"family": "Ham",
"given": "Byung-Joo"
}
],
"container-title-short": "Front Behav Neurosci",
"volume": "20",
"page": "1878769",
"DOI": "10.3389/fnbeh.2026.1878769",
"PMID": "42591615",
"PMCID": "PMC13462048",
"ISSN": "1662-5153",
"publisher": "Frontiers Media SA",
"URL": "https://doi.org/10.3389/fnbeh.2026.1878769",
"language": "en",
"issued": {
"date-parts": [
[
2026,
7,
29
]
]
}
}

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.1038/s41593-026-02301-4
Deep brain stimulation induces white matter remodeling and functional changes to brain-wide networks.
Journal: Nature neuroscience
In common: depression, 4 references
[2] doi:10.1073/pnas.2609814123 [code]
Genetic architectures of brain-related traits are shaped by strong selective constraints.
Journal: Proceedings of the National Academy of Sciences of the United States of America
In common: genetics / omics, cellular / molecular, 4 references
[3] doi:10.1016/j.isci.2026.116429 [code]
&lt;i&gt;HMGA2&lt;/i&gt; regulates fear and growth: Canine GWAS and functional evidence.
Journal: iScience
In common: other, genetics / omics, 3 references
[4] doi:10.1038/s41467-026-73996-z [code]
Genetic architecture of white matter microstructure captured by unsupervised deep representation learning of fractional anisotropy maps.
Journal: Nature communications
In common: h5py, structural MRI / diffusion, genetics / omics, cellular / molecular, 2 references
[5] doi:10.3389/fpain.2026.1850836 [code]
Diffusion tensor imaging in chronic tension-type headache.
Journal: Frontiers in pain research (Lausanne, Switzerland)
In common: structural MRI / diffusion, 3 references
[6] doi:10.1038/s41398-026-04025-2 [code]
Brain energetic landscapes shape state dysregulation in major depressive disorder: a morphological network controllability perspective.
Journal: Translational psychiatry
In common: h5py, depression, 2 references
[7] doi:10.1017/s0033291726104711
Cell-type and spatiotemporal transcriptional signatures of white matter morphometric similarity network alterations in major depressive disorder.
Journal: Psychological medicine
In common: depression, structural MRI / diffusion, genetics / omics, 1 other category, 2 references
[8] doi:10.1038/s41467-026-75193-4 [code]
Multi-ancestry gene expression models amplify transcriptome-wide association study discovery and validation.
Journal: Nature communications
In common: h5py, genetics / omics, cellular / molecular, 2 references
[9] doi:10.24272/j.issn.2095-8137.2025.270
&lt;i&gt;NOCT&lt;/i&gt;, a potential domestication gene impacting circadian regulation and behavioral adaptation during dog domestication.
Journal: Zoological research
In common: other, cellular / molecular, 2 references
[10] doi:10.1038/s41467-026-71803-3 [code]
Charting the transition from in vitro gliogenesis to the in vivo maturation of human glial progenitor cells transplanted into the hypomyelinated mouse brain.
Journal: Nature communications
In common: h5py, genetics / omics, cellular / molecular, 2 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.