forked from trinityrnaseq/trinityrnaseq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Trinity
executable file
·3493 lines (2605 loc) · 122 KB
/
Trinity
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env perl
use strict;
use warnings;
use threads;
no strict qw(subs refs);
use FindBin;
use lib ("$FindBin::RealBin/PerlLib");
use File::Basename;
use Time::localtime;
use Cwd;
use Carp;
use COMMON;
use Getopt::Long qw(:config posix_default no_ignore_case pass_through gnu_compat no_auto_abbrev);
use Pipeliner;
use Fasta_reader;
use List::Util qw(min max);
use Data::Dumper;
my $VERSION = "Trinity-v2.4.0";
BEGIN {
$ENV{TRINITY_HOME} = "$FindBin::RealBin";
}
open (STDERR, ">&STDOUT"); ## capturing stderr and stdout in a single stdout stream
#directory defnintions
my $ROOTDIR = "$FindBin::RealBin";
my $UTILDIR = "$ROOTDIR/util";
my $MISCDIR = "$UTILDIR/misc";
my $INCHWORM_DIR = "$ROOTDIR/Inchworm/bin/";
my $CHRYSALIS_DIR = "$ROOTDIR/Chrysalis";
my $BUTTERFLY_DIR = "$ROOTDIR/Butterfly";
my $JELLYFISH_DIR = "$ROOTDIR/trinity-plugins/jellyfish";
my $COLLECTL_DIR = "$ROOTDIR/trinity-plugins/COLLECTL/collectl";
my $PARAFLY = "$ROOTDIR/trinity-plugins/parafly/bin/ParaFly";
my $TRIMMOMATIC = "$ROOTDIR/trinity-plugins/Trimmomatic/trimmomatic.jar";
my $TRIMMOMATIC_DIR = "$ROOTDIR/trinity-plugins/Trimmomatic";
$ENV{PATH} = "$ROOTDIR/trinity-plugins/BIN:$ENV{PATH}";
# Site specific setup
my $USE_PERL_SCAFFOLDER = 1; # for testing purposes in chrysalis stage
my $KMER_SIZE = 25;
my $MAX_KMER_SIZE = 32;
my $INCHWORM_CUSTOM_PARAMS;
# option list:
my ($seqType, @left_files, @right_files, @single_files, $SS_lib_type, $min_contig_length,
$group_pairs_distance, $jaccard_clip, $show_advanced_options,
$output_directory, $prep_only
);
# defaults:
$output_directory = &create_full_path("trinity_out_dir", 0);
# butterfly opts
$min_contig_length = 200;
$group_pairs_distance = 500;
my $path_reinforcement_distance;
my $PE_path_reinforcement_distance = 25;
my $SE_path_reinforcement_distance = 25;
my $bfly_opts = "";
my $bflyHeapSpaceMax = "4G";
my $bflyHeapSpaceInit = "1G";
my $BFLY_JAR = "";
# butterfly path merging criteria
my $NO_PATH_MERGING = 0;
my $MIN_PER_ID_SAME_PATH; # leave these at the butterfy defaults
my $MAX_DIFFS_SAME_PATH;
my $MAX_INTERNAL_GAP_SAME_PATH;
# misc opts
my $min_kmer_cov = 1;
my $meryl_opts = "";
my $inchworm_cpu = 6;
my $min_percent_read_iworm_kmers = -1; # experimental, off
my $CPU = 2;
my $np = 1;
my $mpiexec = "mpiexec";
my $bflyCPU;
my $bflyCalculateCPU = 0;
my $bflyGCThreads = 2;
my $long_reads = "";
my $LONG_READS_MODE = 0;
## ADVANCED OPTIONS:
## Chrysalis opts
my $min_glue = 2;
my $min_iso_ratio = 0.05;
my $glue_factor = 0.05;
my $max_reads_per_graph = 200000;
my $max_reads_per_loop = 50000000; #MW: Set default to 50M, still fits into main memory
my $min_pct_read_mapping = 0;
my $chrysalis_output_dir = "chrysalis";
my $component_directory;
my $NO_RUN_CHRYSALIS_FLAG = 0;
my $NO_DISTRIBUTED_TRINITY_EXEC = 0;
my $help_flag;
my $advanced_help_flag;
my $SHOW_CITATION_FLAG = 0;
my $show_version_flag = 0;
## Kmer methods
my $kmer_method = "";
## Jellyfish
my $max_memory;
## Grid computing options:
my $grid_exec_toolname = "";
## Performance monitoring options
my $pm_logfile = "Trinity.timing";
my $pm_trinity_startstring;
my $pm_trinity_endstring;
my $pm_trinity_start=0;
my $pm_trinity_end=0;
my $pm_inchworm_start=0;
my $pm_inchworm_end=0;
my $pm_chrysalis_start=0;
my $pm_chrysalis_end=0;
my $pm_butterfly_start=0;
my $pm_butterfly_end=0;
my $pm_left_fa_size=0;
my $pm_right_fa_size=0;
my $pm_single_fa_size=0;
my $pm_trinity_fa_size=0;
my $pm_trinity_arguments="";
my $pm_inchworm_kmers=0;
my $pm_read_count=0;
my $run_with_collectl = 0;
# flush each second, record procs+rest every 5 secs, use only process subsystem
my $collectl_output_directory = "collectl";
my $collectl_pid = 0;
my $collectl_out = "";
my $collectl_titlename = "";
my $start_dir = cwd();
my $COLLECTL_INTERVAL_SECONDS = 60;
## misc other opts, mostly for testing purposes
my $run_as_paired_flag = 0; ## in case we have paired reads in single fasta file, already oriented.
my $weldmer_size = 48;
my $FORCE_INCHWORM_KMER_METHOD = 0;
my $PARALLEL_IWORM_FLAG = 1;
my $NO_PARALLEL_IWORM = 0;
## Quality trimming params
my $RUN_TRIMMOMATIC_FLAG = 0;
my $trimmomatic_quality_trim_params = "ILLUMINACLIP:$TRIMMOMATIC_DIR/adapters/TruSeq3-PE.fa:2:30:10 SLIDINGWINDOW:4:5 LEADING:5 TRAILING:5 MINLEN:25";
## Normalize reads
my $NORMALIZE_READS_FLAG = 0; ## now on by default, unless told not to via --no_normalize_reads! See below for logic.
my $NO_NORMALIZE_READS_FLAG = 0; ## set to turn off normalization (will be turned on if trinity_complete_flag and ! --normalize_reads set.
my $normalize_max_read_cov = 50;
my $normalize_max_pct_stdev = 10000; # effectively turn it off for this application.
my $NORMALIZE_BY_READ_SET = 0;
my $grid_node_CPU = 1;
my $grid_node_max_memory = "1G";
# Note: For the Trinity logo below the backslashes are quoted in order to keep
# them from quoting the character than follows them. "\\" keeps "\ " from occuring.
my $basic_usage = qq^
###############################################################################
#
# ______ ____ ____ ____ ____ ______ __ __
# | || \\ | || \\ | || || | |
# | || D ) | | | _ | | | | || | |
# |_| |_|| / | | | | | | | |_| |_|| ~ |
# | | | \\ | | | | | | | | | |___, |
# | | | . \\ | | | | | | | | | | |
# |__| |__|\\_||____||__|__||____| |__| |____/
#
###############################################################################
#
# Required:
#
# --seqType <string> :type of reads: ('fa' or 'fq')
#
# --max_memory <string> :suggested max memory to use by Trinity where limiting can be enabled. (jellyfish, sorting, etc)
# provided in Gb of RAM, ie. '--max_memory 10G'
#
# If paired reads:
# --left <string> :left reads, one or more file names (separated by commas, no spaces)
# --right <string> :right reads, one or more file names (separated by commas, no spaces)
#
# Or, if unpaired reads:
# --single <string> :single reads, one or more file names, comma-delimited (note, if single file contains pairs, can use flag: --run_as_paired )
#
# Or,
# --samples_file <string> tab-delimited text file indicating biological replicate relationships.
# ex.
# cond_A cond_A_rep1 A_rep1_left.fq A_rep1_right.fq
# cond_A cond_A_rep2 A_rep2_left.fq A_rep2_right.fq
# cond_B cond_B_rep1 B_rep1_left.fq B_rep1_right.fq
# cond_B cond_B_rep2 B_rep2_left.fq B_rep2_right.fq
#
# # if single-end instead of paired-end, then leave the 4th column above empty.
#
####################################
## Misc: #########################
#
# --SS_lib_type <string> :Strand-specific RNA-Seq read orientation.
# if paired: RF or FR,
# if single: F or R. (dUTP method = RF)
# See web documentation.
#
# --CPU <int> :number of CPUs to use, default: $CPU
# --min_contig_length <int> :minimum assembled contig length to report
# (def=$min_contig_length)
#
# --long_reads <string> :fasta file containing error-corrected or circular consensus (CCS) pac bio reads
# (** note: experimental parameter **, this functionality continues to be under development)
#
# --genome_guided_bam <string> :genome guided mode, provide path to coordinate-sorted bam file.
# (see genome-guided param section under --show_full_usage_info)
#
# --jaccard_clip :option, set if you have paired reads and
# you expect high gene density with UTR
# overlap (use FASTQ input file format
# for reads).
# (note: jaccard_clip is an expensive
# operation, so avoid using it unless
# necessary due to finding excessive fusion
# transcripts w/o it.)
#
# --trimmomatic :run Trimmomatic to quality trim reads
# see '--quality_trimming_params' under full usage info for tailored settings.
#
#
# --no_normalize_reads :Do *not* run in silico normalization of reads. Defaults to max. read coverage of $normalize_max_read_cov.
# see '--normalize_max_read_cov' under full usage info for tailored settings.
# (note, as of Sept 21, 2016, normalization is on by default)
#
# --no_distributed_trinity_exec :do not run Trinity phase 2 (assembly of partitioned reads), and stop after generating command list.
#
#
# --output <string> :name of directory for output (will be
# created if it doesn't already exist)
# default( your current working directory: "$output_directory"
# note: must include 'trinity' in the name as a safety precaution! )
#
# --full_cleanup :only retain the Trinity fasta file, rename as \${output_dir}.Trinity.fasta
#
# --cite :show the Trinity literature citation
#
# --verbose :provide additional job status info during the run.
#
# --version :reports Trinity version ($VERSION) and exits.
#
# --show_full_usage_info :show the many many more options available for running Trinity (expert usage).
^;
my $full_usage = qq^
#
# --KMER_SIZE <int> :kmer length to use (default: 25) max=32
#
# --prep :Only prepare files (high I/O usage) and stop before kmer counting.
#
# --no_cleanup :retain all intermediate input files.
#
# --no_version_check :dont run a network check to determine if software updates are available.
#
####################################################
# Inchworm and K-mer counting-related options: #####
#
# --min_kmer_cov <int> :min count for K-mers to be assembled by
# Inchworm (default: $min_kmer_cov)
# --inchworm_cpu <int> :number of CPUs to use for Inchworm, default is min(6, --CPU option)
#
# --no_run_inchworm :stop after running jellyfish, before inchworm. (phase 1, read clustering only)
#
###################################
# Chrysalis-related options: ######
#
# --max_reads_per_graph <int> :maximum number of reads to anchor within
# a single graph (default: $max_reads_per_graph)
# --min_glue <int> :min number of reads needed to glue two inchworm contigs
# together. (default: $min_glue)
#
# --no_bowtie :dont run bowtie to use pair info in chrysalis clustering.
#
# --no_run_chrysalis :stop after running inchworm, before chrysalis. (phase 1, read clustering only)
#
#####################################
### Butterfly-related options: ####
#
# --bfly_opts <string> :additional parameters to pass through to butterfly
# (see butterfly options: java -jar Butterfly.jar ).
# (note: only for expert or experimental use. Commonly used parameters are exposed through this Trinity menu here).
#
#
# Butterfly read-pair grouping settings (used to define 'pair paths'):
#
# --group_pairs_distance <int> :maximum length expected between fragment pairs (default: $group_pairs_distance)
# (reads outside this distance are treated as single-end)
#
# ///////////////////////////////////////////////
# Butterfly default reconstruction mode settings. (no CuffFly or PasaFly custom settings are currently available).
#
# --path_reinforcement_distance <int> :minimum overlap of reads with growing transcript
# path (default: PE: $PE_path_reinforcement_distance, SE: $SE_path_reinforcement_distance)
# Set to 1 for the most lenient path extension requirements.
#
#
# /////////////////////////////////////////
# Butterfly transcript reduction settings:
#
# --no_path_merging : all final transcript candidates are output (including SNP variations, however, some SNPs may be unphased)
#
# By default, alternative transcript candidates are merged (in reality, discarded) if they are found to be too similar, according to the following logic:
#
# (identity=(numberOfMatches/shorterLen) > 95.0% or if we have <= 2 mismatches) and if we have internal gap lengths <= 10
#
# with parameters as:
#
# --min_per_id_same_path <int> default: 98 min percent identity for two paths to be merged into single paths
# --max_diffs_same_path <int> default: 2 max allowed differences encountered between path sequences to combine them
# --max_internal_gap_same_path <int> default: 10 maximum number of internal consecutive gap characters allowed for paths to be merged into single paths.
#
# If, in a comparison between two alternative transcripts, they are found too similar, the transcript with the greatest cumulative
# compatible read (pair-path) support is retained, and the other is discarded.
#
#
# //////////////////////////////////////////////
# Butterfly Java and parallel execution settings.
#
# --bflyHeapSpaceMax <string> :java max heap space setting for butterfly
# (default: $bflyHeapSpaceMax) => yields command
# 'java -Xmx$bflyHeapSpaceMax -jar Butterfly.jar ... \$bfly_opts'
# --bflyHeapSpaceInit <string> :java initial heap space settings for
# butterfly (default: $bflyHeapSpaceInit) => yields command
# 'java -Xms$bflyHeapSpaceInit -jar Butterfly.jar ... \$bfly_opts'
# --bflyGCThreads <int> :threads for garbage collection
# (default: $bflyGCThreads))
# --bflyCPU <int> :CPUs to use (default will be normal
# number of CPUs; e.g., $CPU)
# --bflyCalculateCPU :Calculate CPUs based on 80% of max_memory
# divided by maxbflyHeapSpaceMax
#
# --bfly_jar <string> : /path/to/Butterfly.jar, otherwise default
# Trinity-installed version is used.
#
#
#
################################################################################
#### Quality Trimming Options ####
#
# --quality_trimming_params <string> defaults to: "$trimmomatic_quality_trim_params"
#
################################################################################
#### In silico Read Normalization Options ###
#
# --normalize_max_read_cov <int> defaults to 50
# --normalize_by_read_set run normalization separate for each pair of fastq files,
# then one final normalization that combines the individual normalized reads.
# Consider using this if RAM limitations are a consideration.
#
################################################################################
#### Genome-guided de novo assembly
#
# * required:
#
# --genome_guided_max_intron <int> :maximum allowed intron length (also maximum fragment span on genome)
#
# * optional:
#
# --genome_guided_min_coverage <int> :minimum read coverage for identifying and expressed region of the genome. (default: 1)
#
# --genome_guided_min_reads_per_partition <int> :default min of 10 reads per partition
#
#
#######################################################################
# Trinity phase 2 (parallel assembly of read clusters) Options: #######
#
# --grid_exec <string> :your command-line utility for submitting jobs to the grid.
# This should be a command line tool that accepts a single parameter:
# \${your_submission_tool} /path/to/file/containing/commands.txt
# and this submission tool should exit(0) upon successful
# completion of all commands.
#
# --grid_node_CPU <int> number of threads for each parallel process to leverage. (default: $grid_node_CPU)
#
# --grid_node_max_memory <string> max memory targeted for each grid node. (default: $grid_node_max_memory)
#
# The --grid_node_CPU and --grid_node_max_memory are applied as
# the --CPU and --max_memory parameters for the Trinity jobs run in
# Trinity Phase 2 (assembly of read clusters)
#
^;
my $usage_synopsis = qq^#
#
###############################################################################
#
# *Note, a typical Trinity command might be:
#
# Trinity --seqType fq --max_memory 50G --left reads_1.fq --right reads_2.fq --CPU 6
#
#
# and for Genome-guided Trinity:
#
# Trinity --genome_guided_bam rnaseq_alignments.csorted.bam --max_memory 50G\
# --genome_guided_max_intron 10000 --CPU 6
#
# see: $FindBin::RealBin/sample_data/test_Trinity_Assembly/
# for sample data and 'runMe.sh' for example Trinity execution
#
# For more details, visit: http://trinityrnaseq.github.io
#
###############################################################################
^;
my $advanced_usage = <<_ADVANCEDUSAGE_;
###################################################################################
## Not intended for users, instead for experimentation by developers ##
###################################################################################
#
#
# Inchworm-related options:
#
# --INCHWORM_CUSTOM_PARAMS <string> :additional parameters to be passed on to Inchworm
# --FORCE_INCHWORM_KMER_METHOD :uses inchworm built-in kmer cataloger instead of jellyfish (not recommended)
# --NO_PARALLEL_IWORM : turn off parallel iworm assembly
# --iworm_opts <string> : options for inchworm
#
#
# Chyrsalis-related options:
#
# --min_pcnt_read_iworm_kmers <int> :min percentage of a read sequence that must be composed of inchworm kmers to be pursued
# by chrysalis (default: $min_percent_read_iworm_kmers) note: off if < 0
#
# --min_iso_ratio <float> :min fraction of average kmer coverage between two iworm contigs
# required for gluing. (default: $min_iso_ratio)
# --glue_factor <float> :fraction of max (iworm pair coverage) for read glue support (default: $glue_factor)
#
# --max_reads_per_loop <int> :maximum number of reads to read into
# memory at once (default: $max_reads_per_loop)
# --min_pct_read_mapping <int> :minimum percent of a reads kmers that must map to an
# inchworm bundle (aka. component) default: 0
#
# --bowtie_components :use bowtie2 to generate readsToTranscripts mappings
#
#
# Other:
# --monitoring :use collectl to monitor all steps of Trinity
# --monitor_sec <int> : number of seconds for each interval of runtime monitoring (default: $COLLECTL_INTERVAL_SECONDS)
#
# --bypass_java_version_check : skip check for required java version 1.7
#
# --long_reads_mode : run in long reads mode (requires --single and the long reads integrated with LR$| accession prefixes.
#
_ADVANCEDUSAGE_
;
my $usage = $basic_usage . $usage_synopsis;
unless (@ARGV) {
die "$usage\n";
}
# Log command line parameters for performance monitoring
foreach (@ARGV) {
$pm_trinity_arguments = $pm_trinity_arguments . " " . $_;
};
my $NO_CLEANUP = 0;
my $FULL_CLEANUP = 0;
my $NO_BOWTIE = 0;
my $BOWTIE_COMP = 0;
my $NO_RUN_INCHWORM_FLAG = 0;
my $JELLY_S;
my $PASAFLY_MODE = 0;
my $CUFFFLY_MODE = 0;
my $full_usage_info_flag;
my $NO_TRIPLET_LOCK;
## Genome-guided params:
my $genome_guided_max_intron;
my $genome_guided_bam;
my $genome_guided_min_coverage = 1;
my $genome_guided_min_reads_per_partition = 10;
my $genome_guided_just_prep_flag = 0;
## trinity complete flag
my $TRINITY_COMPLETE_FLAG = 0;
my @ORIG_ARGS = @ARGV;
my $CHRYSALIS_DEBUG_WELD_ALL = 0;
my $iworm_opts = "";
my $bypass_java_version_check = 0;
my $VERBOSE = 0;
my $ANANAS_DIR = "";
my $NO_VERSION_CHECK = 0;
my $samples_file = "";
&GetOptions(
'h|help' => \$help_flag,
'advanced_help' => \$advanced_help_flag,
'show_full_usage_info' => \$full_usage_info_flag,
'verbose' => \$VERBOSE,
'verbose_level=i' => \$VERBOSE,
'no_version_check' => \$NO_VERSION_CHECK,
## general opts
"seqType=s" => \$seqType,
"left=s{,}" => \@left_files,
"right=s{,}" => \@right_files,
"single=s{,}" => \@single_files,
"samples_file=s" => \$samples_file,
"SS_lib_type=s" => \$SS_lib_type,
"long_reads=s" => \$long_reads,
"long_reads_mode" => \$LONG_READS_MODE,
"output=s" => \$output_directory,
"min_contig_length=i" => \$min_contig_length,
"jaccard_clip" => \$jaccard_clip,
"cite" => \$SHOW_CITATION_FLAG,
'CPU=i' => \$CPU,
'np=i' => \$np,
'mpiexec=s' => \$mpiexec,
'prep' => \$prep_only,
'KMER_SIZE=i' => \$KMER_SIZE,
# Quality trimming:
'trimmomatic' => \$RUN_TRIMMOMATIC_FLAG,
'quality_trimming_params=s' => \$trimmomatic_quality_trim_params,
# In silico read normalization
'normalize_reads' => \$NORMALIZE_READS_FLAG, ## left here for backwards compatibility, set to 1 by default so a noop on setting.
'no_normalize_reads' => \$NO_NORMALIZE_READS_FLAG, ## new setting to turn it off.
'normalize_max_read_cov=i' => \$normalize_max_read_cov,
'normalize_by_read_set' => \$NORMALIZE_BY_READ_SET,
# Butterfly opts
"group_pairs_distance=i" => \$group_pairs_distance,
'bfly_opts=s' => \$bfly_opts,
'bflyHeapSpaceMax=s' => \$bflyHeapSpaceMax,
'bflyHeapSpaceInit=s' => \$bflyHeapSpaceInit,
'bflyGCThreads=i' => \$bflyGCThreads,
'bflyCPU=i' => \$bflyCPU,
'bflyCalculateCPU' => \$bflyCalculateCPU,
'bfly_jar=s' => \$BFLY_JAR,
'path_reinforcement_distance=i' => \$path_reinforcement_distance,
'no_path_merging' => \$NO_PATH_MERGING,
'min_per_id_same_path=i' => \$MIN_PER_ID_SAME_PATH,
'max_diffs_same_path=i' => \$MAX_DIFFS_SAME_PATH,
'max_internal_gap_same_path=i' => \$MAX_INTERNAL_GAP_SAME_PATH,
'PasaFly' => \$PASAFLY_MODE,
'CuffFly' => \$CUFFFLY_MODE,
# Inchworm & kmer catalog opts
'min_kmer_cov=i' => \$min_kmer_cov,
'inchworm_cpu=i' => \$inchworm_cpu,
'FORCE_INCHWORM_KMER_METHOD' => \$FORCE_INCHWORM_KMER_METHOD,
'INCHWORM_CUSTOM_PARAMS=s' => \$INCHWORM_CUSTOM_PARAMS,
'no_run_inchworm' => \$NO_RUN_INCHWORM_FLAG,
'iworm_opts=s' => \$iworm_opts,
'max_memory|M=s' => \$max_memory, # in GB
# Chrysalis -related opts
'min_glue=i' => \$min_glue,
'glue_factor=f' => \$glue_factor,
'min_iso_ratio=f' => \$min_iso_ratio,
'min_pcnt_read_iworm_kmers=i' => \$min_percent_read_iworm_kmers,
'max_reads_per_graph=i' => \$max_reads_per_graph,
'max_reads_per_loop=i' => \$max_reads_per_loop,
'min_pct_read_mapping=i' => \$min_pct_read_mapping,
'weldmer_size=i' => \$weldmer_size,
"no_bowtie" => \$NO_BOWTIE,
"bowtie_components" => \$BOWTIE_COMP,
"no_run_chrysalis" => \$NO_RUN_CHRYSALIS_FLAG,
"show_advanced_options" => \$show_advanced_options,
# Grid computing options
'grid_exec=s' => \$grid_exec_toolname,
"grid_node_CPU=i" => $grid_node_CPU,
"grid_node_max_memory=s" => $grid_node_max_memory,
# misc
'run_as_paired' => \$run_as_paired_flag,
'no_cleanup' => \$NO_CLEANUP,
'full_cleanup' => \$FULL_CLEANUP,
'version' => \$show_version_flag,
'monitoring' => \$run_with_collectl,
'monitor_sec=i' => \$COLLECTL_INTERVAL_SECONDS,
'no_distributed_trinity_exec' => \$NO_DISTRIBUTED_TRINITY_EXEC,
# hidden (don't look here! ;)
'KMER_SIZE=i' => \$KMER_SIZE,
'jelly_s=i' => \$JELLY_S,
'NO_PARALLEL_IWORM' => \$NO_PARALLEL_IWORM,
'chrysalis_debug_weld_all' => \$CHRYSALIS_DEBUG_WELD_ALL,
# genome guided
"genome_guided_bam=s" => \$genome_guided_bam,
"genome_guided_max_intron=i" => \$genome_guided_max_intron,
"genome_guided_min_coverage=i" => \$genome_guided_min_coverage,
"genome_guided_min_reads_per_partition=i" => \$genome_guided_min_reads_per_partition,
"genome_guided_just_prep" => \$genome_guided_just_prep_flag,
"trinity_complete" => \$TRINITY_COMPLETE_FLAG,
"bypass_java_version_check" => \$bypass_java_version_check,
"ananas_dir=s" => \$ANANAS_DIR,
);
my @__ALL_TRINITY_PARAMS = qw(
h
help
advanced_help
show_full_usage_info
verbose
no_version_check
seqType
left
right
single
SS_lib_type
long_reads
long_reads_mode
output
min_contig_length
jaccard_clip
cite
CPU
np
mpiexec
prep
KMER_SIZE
trimmomatic
quality_trimming_params
normalize_reads
no_normalize_reads
normalize_max_read_cov
normalize_by_read_set
group_pairs_distance
bfly_opts
bflyHeapSpaceMax
bflyHeapSpaceInit
bflyGCThreads
bflyCPU
bflyCalculateCPU
bfly_jar
path_reinforcement_distance
no_path_merging
min_per_id_same_path
max_diffs_same_path
max_internal_gap_same_path
PasaFly
CuffFly
min_kmer_cov
inchworm_cpu
FORCE_INCHWORM_KMER_METHOD
INCHWORM_CUSTOM_PARAMS
no_run_inchworm
iworm_opts
max_memory
M
min_glue
glue_factor
min_iso_ratio
min_pcnt_read_iworm_kmers
max_reads_per_graph
max_reads_per_loop
min_pct_read_mapping
weldmer_size
no_bowtie
bowtie_comp
no_run_chrysalis
grid_exec
show_advanced_options
run_as_paired
no_cleanup
full_cleanup
version
monitoring
no_distributed_trinity_exec
jelly_s
NO_PARALLEL_IWORM
chrysalis_debug_weld_all
genome_guided_bam
genome_guided_max_intron
genome_guided_min_coverage
genome_guided_min_reads_per_partition
genome_guided_just_prep
trinity_complete
bypass_java_version_check
ananas_dir
samples_file
);
my %ACCEPTABLE_OPTS = map { + $_ => 1} @__ALL_TRINITY_PARAMS;
my $opts_not_recognized_flag = 0;
for my $opt (@ARGV) {
if ($opt =~ /^-+(\S+)/) {
my $opt_part = $1;
unless ($ACCEPTABLE_OPTS{$opt_part}) {
print STDERR "ERROR, don't recognize parameter: $opt\n";
$opts_not_recognized_flag = 1;
}
}
}
if ($opts_not_recognized_flag) {
die "Please review usage info for accepted parameters.\n";
}
if ($SHOW_CITATION_FLAG) {
&show_lit_citation();
exit(0);
}
my $sort_exec = &COMMON::get_sort_exec($CPU);
if ($full_usage_info_flag) {
$usage = $basic_usage . $full_usage . $usage_synopsis;
die "$usage\n";
}
if ($advanced_help_flag) {
die "$advanced_usage\n";
}
if ($help_flag) {
die "$usage\n";
}
if ($show_version_flag) {
&version_check();
exit(1);
}
## basic options check:
unless ($max_memory &&
($genome_guided_bam ||
($seqType && $seqType =~ /^(fq|fa)$/
&&
($samples_file || (@left_files && @right_files) || @single_files) )
)
) {
die "Must specify basic parameters: ex. Trinity --seqType fq --single reads.fq --max_memory 10G ";
}
my $GRAPH_FROM_FASTA_CUSTOM_PARAMS = "";
my $GRAPH_FROM_FASTA_KK = 2*($KMER_SIZE-1);
if ($TRINITY_COMPLETE_FLAG) {
###############################################
## force some options for phase 2 read assembly
###############################################
## iworm opts
unless ($iworm_opts =~ /min_seed_entropy/) {
$iworm_opts .= " --min_seed_entropy 0.5 ";
}
unless ($iworm_opts =~ /min_ratio_non_error/) {
$iworm_opts .= " --min_ratio_non_error 0.02 ";
}
$PARALLEL_IWORM_FLAG = 0;
$glue_factor = 0.03;
unless ($NORMALIZE_READS_FLAG) {
## do not normalize by default when in trinity-complete mode. Normalizion should have been done earlier.
$NO_NORMALIZE_READS_FLAG = 1;
}
}
if ($NO_CLEANUP && $FULL_CLEANUP) {
die "cannot set --no_cleanup and --full_cleanup as they contradict";
}
if ($KMER_SIZE > $MAX_KMER_SIZE) {
die "Error, kmer size can be at most $MAX_KMER_SIZE ";
}
if ($NO_PARALLEL_IWORM) {
# turn it off.
$PARALLEL_IWORM_FLAG = 0;
}
my $MIN_IWORM_LEN = $KMER_SIZE;
if (@ARGV) {
die "Error, do not understand options: @ARGV\n";
}
if ($run_with_collectl && $^O !~ /linux/i) {
print STDERR "WARNING, --monitoring can only be used on linux. Turning it off.\n\n";
$run_with_collectl = 0;
}
unless ($BFLY_JAR) {
$BFLY_JAR = "$BUTTERFLY_DIR/Butterfly.jar";
}
unless ($NO_NORMALIZE_READS_FLAG) {
$NORMALIZE_READS_FLAG = 1;
}
if ($samples_file) {
&parse_samples_file($samples_file, \@single_files, \@left_files, \@right_files);
}
if (@left_files && @single_files) {
die "Error, cannot mix PE and SE reads by using --left, --right, and --single. See Trinity FAQ for how to combine SE and PE data";
}
if ($SS_lib_type) {
unless ($SS_lib_type =~ /^(R|F|RF|FR)$/) {
die "Error, unrecognized SS_lib_type value of $SS_lib_type. Should be: F, R, RF, or FR\n";
}
if (@single_files) {
if ($run_as_paired_flag && ! $TRINITY_COMPLETE_FLAG) {
die "Error, if you have paired-end reads and want to run as strand-specific, then you must specify the --left and --right parameters";
}
if (length($SS_lib_type) != 1) {
die "Error, with --single reads, the --SS_lib_type can be 'F' or 'R' only.\n";
}
}
if (@left_files && @right_files) {
if (length($SS_lib_type) != 2) {
die "Error, with paired end reads, the --SS_lib_type can be 'RF' or 'FR' only.\n";
}
}
}
unless ($genome_guided_bam || (@left_files && @right_files) || @single_files ) {
die "Error, need either options 'left' and 'right' or option 'single' or 'genome_guided_bam'\n";
}
unless ($genome_guided_bam) {
unless ($seqType) {
die "Error, need --seqType specified\n";
}
}
if (@left_files) {
@left_files = split(",", join(",", @left_files));
print STDERR "Left read files: " . Dumper(\@left_files) unless ($TRINITY_COMPLETE_FLAG);
}
if (@right_files) {
@right_files = split(",", join(",", @right_files));
print STDERR "Right read files: " . Dumper(\@right_files) unless ($TRINITY_COMPLETE_FLAG);
}
if (@single_files) {
@single_files = split(",", join(",", @single_files));
print STDERR "Single read files: " . Dumper(\@single_files) unless ($TRINITY_COMPLETE_FLAG);
}
if ($min_iso_ratio > 1) {
die "Error, --min_iso_ratio should be <= 1 \n";
}
## keep the original 'xG' format string for the --JM option, then calculate the numerical value for jellyfish_ram
my $jellyfish_ram = $max_memory; ## this one is used in the Chrysalis exec string
if ($jellyfish_ram) {
$jellyfish_ram =~ /^([\d\.]+)G$/ or die "Error, cannot parse jellyfish_ram value of $jellyfish_ram. Set it to 'xG' where x is a numerical value\n";
$jellyfish_ram = $1;
$jellyfish_ram *= 1024**3; # convert to from gig to bytes
}
else {
die "Error, must specify max memory for jellyfish to use, eg. --max_memory 10G \n";
}
## Check Java version:
unless ($NO_RUN_INCHWORM_FLAG || $NO_RUN_CHRYSALIS_FLAG || $bypass_java_version_check || $TRINITY_COMPLETE_FLAG) {
my $java_version = `java -Xmx64m -version 2>&1 `;
my $JAVA_VERSION_REQUIRED = 8;
if ($java_version =~ /(java|openjdk) version \"1\.(\d)\./) {
my $version_id = $2;
if ($version_id < $JAVA_VERSION_REQUIRED) {
die "Error, Trinity requires access to Java version 1.$JAVA_VERSION_REQUIRED or higher. Currently installed version is: $java_version";
}
}
else {
print STDERR "\n\n\n********************************************************************\n"
. "** Warning, Trinity cannot determine which version of Java is being used. Version 1.$JAVA_VERSION_REQUIRED is required. \n\nAttempting to continue in 30 seconds\n"
. "********************************************************************\n\n\n";
sleep(30);
}
}
unless ($NO_VERSION_CHECK || $TRINITY_COMPLETE_FLAG) {
&version_check();
}