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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
|
%global _empty_manifest_terminate_build 0
Name: python-predectorutils
Version: 0.9.1
Release: 1
Summary: Utility scripts for the predector pipeline.
License: Apache 2.0
URL: https://github.com/ccdmb/predector
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/a0/97/de3fdbf8f430eea37ff02c01a923a604511e4bf4078da454f3b8f4d8b4a9/predectorutils-0.9.1.tar.gz
BuildArch: noarch
Requires: python3-biopython
Requires: python3-pandas
Requires: python3-numpy
Requires: python3-xgboost
Requires: python3-intervaltree
Requires: python3-check-manifest
Requires: python3-scipy
Requires: python3-scikit-learn
Requires: python3-jupyter
Requires: python3-matplotlib
Requires: python3-seaborn
Requires: python3-pandas
Requires: python3-coverage
Requires: python3-pytest
Requires: python3-mypy
Requires: python3-types-setuptools
%description
# predector-utils
Utilities for running the predector pipeline.
This is where the models and more extensive utility scripts are developed.
All command line tools are accessible under the main command `predutils`.
## `predutils load_db`
Load a line-delimited JSON into an SQLite database.
Basic usage:
```bash
predutils load_db results.db results.ldjson
```
Options:
```
--replace-name
Replace record names with the string 'd'.
--drop-null-dbversion
Don't enter records requiring a database but have no database version specified.
--mem <float>
Use this much RAM for the SQLite cache. Set this to at most half of the total ram available.
--include ANALYSIS [ANALYSIS ...]
Only include these analyses, specify multiple with spaces.
--exclude ANALYSIS [ANALYSIS ...]
Exclude these analyses, specify multiple with spaces. Overrides analyses specified in --include.
```
If you are using this to set up a pre-computed database, specify the `--replace-name`, `--drop-null-dbversion` flags which will make sure any duplicate entries are excluded.
It is also recommended that you exclude results that are faster to recompute than to enter and fetch from the database, including `pepstats`, `kex2_cutsite`, and `rxlr_like_motif`.
This will be relatively fast for small to medium datasets, but can take several hours for many millions of entries.
Setting the `--mem` option is also a good idea to speed up inserting larger datasets.
## `predutils r2js`
Convert the output of one of the analyses into a common [line delimited JSON](http://ndjson.org/) format.
The json records retain all information from the original output files, but are much easier to parse because each line is just JSON.
Basic usage:
```bash
predutils r2js \
-o outfile.ldjson \
--software-version 1.0 \
--database-version 1.0 \
--pipeline-version 0.0.1 \
pfamscan \
pfamscan_results.txt \
in.fasta
```
Analyses available to parse in place of `pfamscan` are:
`signalp3_nn`, `signalp3_hmm`, `signalp4`, `signalp5`, `deepsig`, `phobius`, `tmhmm`,
`deeploc`, `targetp_plant` (v2), `targetp_non_plant` (v2), `effectorp1`, `effectorp2`,
`apoplastp`, `localizer`, `pfamscan`, `dbcan` (HMMER3 domtab output), `phibase` \*, `pepstats`,
`effectordb`, `kex2_cutsite`, and `rxlr_like_motif`.
\* assumes search with MMseqs with tab delimited output format columns: query, target, qstart, qend, qlen, tstart, tend, tlen, evalue, gapopen, pident, alnlen, raw, bits, cigar, mismatch, qcov, tcov.
## `predutils encode`
Preprocess some fasta files.
1. Strips trailing `*` amino acids from sequences, removes `-` characters, replaces internal `*`s and other redundant/non-standard amino acids with `X`, and converts sequences to uppercase.
2. removes duplicate sequence using a checksum, saving the mapping table to recover the duplicates at the end of the analysis.
3. Replace the names of the deduplicated sequences with a short simple one.
Basic usage:
```bash
predutils encode \
output.fasta \
output_mapping.tsv \
input_fastas/*
```
Note that it can take multiple input fasta files, and the filename is saved alongside the sequences in the output mapping table to recover that information.
By default, the temporary names will be `SR[A-Z0-9]5` e.g. `SR003AB`.
You can change the prefix (default `SR`) with the `--prefix` flag, and the number of id characters (default 5) with the `--length` parameter.
## `predutils split_fasta`
Splits a fasta files into several files each with a maximum of n sequences.
Basic usage:
```bash
predutils split_fasta --template 'chunk{index}.fasta' --size 100 in.fasta
```
The `--template` parameter accepts python `.format` style string formatting, and
is provided the variables `fname` (the input filename) and `index` (the chunk number starting at 1).
To pad the numbers with zeros for visual ordering in directories, use the something like `--template '{fname}.{index:0>4}.fasta'`.
Directories in the template will be created for you if they don't exist.
## `predutils precomputed`
Takes a database and some sequences and uses the sequence checksums to decide what has already been computed.
Outputs the precomputed results if `-o` is set.
Writes fasta for the remaining sequences to be computed.
The analyses and software versions to check for in the database are specified as a tab separated file to `analyses`.
```
usage: predutils precomputed [-h] [-o OUTFILE] [-t TEMPLATE] [--mem MEM] db analyses infasta
positional arguments:
db Where the sqlite database is
analyses A 3 column tsv file, no header. 'analysis<tab>software_version<tab>database_version'. database_version should be empty string if None.
infasta The fasta file to parse as input. Cannot be stdin.
optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the precomputed ldjson results to.
-t TEMPLATE, --template TEMPLATE
A template for the output filenames. Can use python `.format` style variable analysis. Directories will be created.
--mem MEM The amount of RAM in gibibytes to let SQLite use for cache.
```
## `predutils decode`
The other end of `predutils encode`.
Takes the common line delimited format from analyses and separates them back
out into the original filenames.
```bash
predutils decode [-h] [-t TEMPLATE] [--mem MEM] db map
positional arguments:
db Where the sqlite database is
map Where to save the id mapping file.
optional arguments:
-h, --help show this help message and exit
-t TEMPLATE, --template TEMPLATE
What to name the output files.
--mem MEM The amount of RAM in gibibytes to let SQLite use for cache.
predutils decode \
--template 'decoded/{filename}.ldjson' \
results.db \
output_mapping.tsv
```
We use the template flag to indicate what the filename output should be, using python format
style replacement. Available values to `--template` are `filename` and `filename_noext`.
The latter is just `filename` without the last extension.
## `predutils tables`
Take the common line delimited output from `predutils r2js` and recover a tabular version of the raw data.
Output filenames are controlled by the `--template` parameter, which uses python format style replacement.
Currently, `analysis` is the only value available to the template parameter.
Directories in the template will be created automatically.
```
predutils tables [-h] [-t TEMPLATE] [--mem MEM] db
positional arguments:
db Where to store the database
optional arguments:
-h, --help show this help message and exit
-t TEMPLATE, --template TEMPLATE
A template for the output filenames. Can use python `.format` style variable analysis. Directories will be created.
--mem MEM The amount of RAM in gibibytes to let SQLite use for cache.
predutils tables \
--template "my_sample-{analysis}.tsv" \
results.db
```
## `predutils gff`
Take the common line-delimited json output from `predutils r2js` and get a GFF3 formatted
set of results for analyses with a positional component (e.g. signal peptides, transmembrane domains, alignment results).
```
predutils gff \
--outfile "my_sample.gff3" \
results.ldjson
```
By default, mmseqs and HMMER search results will be filtered by the built in significance thresholds.
To include all matches in the output (and possibly filter by your own criterion) supply the flag `--keep-all`.
## `predutils rank`
Take a database of results entered by `load_db` and get a summary table
that includes all of the information commonly used for effector prediction, as well as
a scoring column to prioritise candidates.
```
predutils rank \
--outfile my_samples-ranked.tsv \
results.db
```
To change that Pfam or dbCAN domains that you consider to be predictive of effectors,
supply a text file with each pfam or dbcan entry on a new line (do not include pfam version number or `.hmm` in the ids) to the parameters `--dbcan` or `--pfam`.
You can also change the weights for how the score columns are calculated.
See `predutils rank --help` for a full list of parameters.
## `predutils regex`
```
predutils regex [-h] [-o OUTFILE] [-l] [-k {kex2_cutsite,rxlr_like_motif,custom}] [-r REGEX] INFILE
positional arguments:
INFILE The input fasta file.
optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the output to. Default: stdout
-l, --ldjson Write the output as ldjson rather than tsv.
-k {kex2_cutsite,rxlr_like_motif,custom}, --kind {kex2_cutsite,rxlr_like_motif,custom}
Which regular expressions to search for. If custom you must specify a regular expression to --regex. Default: custom.
-r REGEX, --regex REGEX
The regular expression to search for. Ignored if --kind is not custom.
```
## `predutils dump_db`
```
predutils dump_db [-h] [-o OUTFILE] [--mem MEM] db
positional arguments:
db The database to dump results from.
optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the output to. Default: stdout
--mem MEM The amount of RAM in gibibytes to let SQLite use for cache.
```
## `predutils map_to_genome`
This script projects the protein GFF file from the results into genome coordinates based on the GFF used to extract the proteins.
This is intended to support visualisation and selection of candidates in genome browsers like JBrowse or Apollo.
```
usage: predutils map_to_genome [-h] [-o OUTFILE] [--split {source,type}] [--no-filter-kex2] [--id ID_FIELD] genes annotations
positional arguments:
genes Gene GFF to use.
annotations Annotation GFF to use (i.e. the GFF3 output of predector)
options:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the output to. If using the --split parameter this
becomes the prefix. Default: stdout
--split {source,type}
Output distinct GFFs for each analysis or type of feature.
--no-filter-kex2 Output kex2 cutsites even if there is no signal peptide
--id ID_FIELD What GFF attribute field corresponds to your protein feature seqids?
Default uses the Parent field. Because some fields (like Parent)
can have multiple values, we'll raise an error if there is more
than 1 unique value. Any CDSs missing the specified
field (e.g. ID) will be skipped.
```
Pay attention to the `--id` parameter. This determines how the protein ID from the predector output will be matched to the genome GFF3.
By default it looks at the `Parent` attribute, as this is the default name from many GFF protein extraction tools.
But any attribute in the 9th column of the GFF can be used, e.g. to use the CDS feature `ID`, use `--id ID`.
This script will only consider records with type `CDS`, and matches names exactly (no partial matches).
`--split` provides a convenience function to split the GFFs into multiple GFFs based on type or analysis.
This is to facilitate loading the different features/analyses as separate tracks in the genome browser.
## `predutils score_to_genome`
This script plots numeric scores from the predector ranked table at the CDS coordinates from the GFF used to extract the proteins.
This is intended to support visualisation and selection of candidates from genome browsers like JBrowse or Apollo.
```
usage: predutils scores_to_genome [-h] [-o OUTFILE] [--target TARGET [TARGET ...]] \
[--id ID_FIELD] [--reducer {min,max,mean,median}] genes annotations
positional arguments:
genes Gene GFF to use.
annotations ranking table to use (i.e. the -ranked.tsv output of predector)
options:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the output to. Default: stdout
--target TARGET [TARGET ...]
Only output these columns into the bedgraph file.
By default writes a multi bedgraph with all columns.
--id ID_FIELD What GFF attribute field corresponds to your protein feature seqids?
Default uses the Parent field. Because some fields (like Parent)
can have multiple values, we'll raise an error if there is more
than 1 unique value. Any CDSs missing the specified
--reducer {min,max,mean,median}
How should we combine scores if two features overlap?
```
As with the `map_to_genome` command, you should ensure that the protein names (in the first column of the `-ranked.tsv` table), match with the attribute in the 9th column of the GFF3 file.
Because multiple CDS features can overlap (e.g. if there are alternative splicing patterns), we must combine those scores somehow so that a single value is associated with the genomic region.
This can be specified with the `--reducer` parameter which takes the maximum value by default (e.g. the highest effectorP score). But if instead you wanted the average use `--reducer mean`.
By default this script outputs a multi-bedgraph file with all numeric columns.
But if you only wish to output a subset of those columns, you can provide them as a space separated list to the `--target` parameter.
Note that an error will be raised if you try to access a non-numeric column.
If the `--target` parameter comes directly before the two positional arguments, you need to indicate where the space separated list stops with a `--`.
e.g.
```
predutils scores_go_genome --id ID --target effector_score apoplastp effectorp2 -- mygenes.gff3 mygenes-ranked.tsv
```
To split the output into single column bedgraphs you can use the following to extract one bedgraph per value column.
```
#!/usr/bin/env bash
set -euo pipefail
# OPTIONAL
# BGTOBW_EXE="bedGraphToBigWig" # This comes from the UCSC toolkit, or here: http://hgdownload.soe.ucsc.edu/admin/exe/
INFILE=$1
FAI=$2
PREFIX=$3
COLUMNS=( $(head -n 1 "${INFILE}" | cut -f4-) )
for i in "${!COLUMNS[@]}"
do
idx=$(( ${i} + 4 ))
col="${COLUMNS[${i}]}"
cut -f1,2,3,${idx} "${INFILE}" | tail -n+2 | awk '$4 != "NA"' > "${PREFIX}${col}.bedgraph"
# OPTIONAL
# ${BGTOBW_EXE} "${PREFIX}${col}.bedgraph" "${FAI}" "${PREFIX}${col}.bw"
done
```
This is useful for converting the tracks into bigwig files (which only support a single value), suitable for use with Jbrowse or Apollo.
## `predutils ipr_to_gff`
This program creates a GFF3 file in protein coordinates based on an InterProScan (5+) xml output file.
While interproscan _can_ output a GFF3 file of it's own, it doesn't include the domain names or InterPro/GO term annotations etc.
This program gives you a much richer output.
```
usage: predutils ipr_to_gff [-h] [-o OUTFILE] [--namespace NAMESPACE] xml
positional arguments:
xml Interproscan XML file.
optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the GFF output to. Default: stdout
```
## `predutils prot_to_genome`
This program is like `map_to_genome` but it doesn't do anything that is specialised to handling Predector output.
This _should_ be able to map any protein-coordinate GFF onto a genome, but it was developed to transfer interproscan results output by the `ipr_to_gff` tool.
```
usage: predutils prot_to_genome [-h] [-o OUTFILE] [--split] [--id ID_FIELD] genes annotations
positional arguments:
genes Gene GFF to use.
annotations Annotation GFF in protein coordinates
optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the output to. If using the --split parameter this becomes the prefix. Default: stdout
--split Output separate GFFs for each "source" in the GFF.
--id ID_FIELD What GFF attribute field corresponds to your protein feature seqids? Default uses the Parent field. Because some fields (like Parent) can have multiple values, we'll raise an error if there is more than 1 unique value. Any CDSs missing the specified
field (e.g. ID) will be skipped.
```
Note that we don't sort the output.
If you're using tools downstream that require a sorted file, e.g. TABIX, you can mix and match from the following.
This just happens to create suitable inputs for the GFF3+TABIX input type for Jbrowse.
```
FNAME="mapped.gff3"
(grep "^#" "${FNAME}"; grep -v "^#" "${FNAME}" | sort -k1,1 -k4,4n) | bgzip > "${FNAME}.gz"
bgzip --keep --reindex "${FNAME}.gz"
tabix -p gff "${FNAME}.gz"
```
%package -n python3-predectorutils
Summary: Utility scripts for the predector pipeline.
Provides: python-predectorutils
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-predectorutils
# predector-utils
Utilities for running the predector pipeline.
This is where the models and more extensive utility scripts are developed.
All command line tools are accessible under the main command `predutils`.
## `predutils load_db`
Load a line-delimited JSON into an SQLite database.
Basic usage:
```bash
predutils load_db results.db results.ldjson
```
Options:
```
--replace-name
Replace record names with the string 'd'.
--drop-null-dbversion
Don't enter records requiring a database but have no database version specified.
--mem <float>
Use this much RAM for the SQLite cache. Set this to at most half of the total ram available.
--include ANALYSIS [ANALYSIS ...]
Only include these analyses, specify multiple with spaces.
--exclude ANALYSIS [ANALYSIS ...]
Exclude these analyses, specify multiple with spaces. Overrides analyses specified in --include.
```
If you are using this to set up a pre-computed database, specify the `--replace-name`, `--drop-null-dbversion` flags which will make sure any duplicate entries are excluded.
It is also recommended that you exclude results that are faster to recompute than to enter and fetch from the database, including `pepstats`, `kex2_cutsite`, and `rxlr_like_motif`.
This will be relatively fast for small to medium datasets, but can take several hours for many millions of entries.
Setting the `--mem` option is also a good idea to speed up inserting larger datasets.
## `predutils r2js`
Convert the output of one of the analyses into a common [line delimited JSON](http://ndjson.org/) format.
The json records retain all information from the original output files, but are much easier to parse because each line is just JSON.
Basic usage:
```bash
predutils r2js \
-o outfile.ldjson \
--software-version 1.0 \
--database-version 1.0 \
--pipeline-version 0.0.1 \
pfamscan \
pfamscan_results.txt \
in.fasta
```
Analyses available to parse in place of `pfamscan` are:
`signalp3_nn`, `signalp3_hmm`, `signalp4`, `signalp5`, `deepsig`, `phobius`, `tmhmm`,
`deeploc`, `targetp_plant` (v2), `targetp_non_plant` (v2), `effectorp1`, `effectorp2`,
`apoplastp`, `localizer`, `pfamscan`, `dbcan` (HMMER3 domtab output), `phibase` \*, `pepstats`,
`effectordb`, `kex2_cutsite`, and `rxlr_like_motif`.
\* assumes search with MMseqs with tab delimited output format columns: query, target, qstart, qend, qlen, tstart, tend, tlen, evalue, gapopen, pident, alnlen, raw, bits, cigar, mismatch, qcov, tcov.
## `predutils encode`
Preprocess some fasta files.
1. Strips trailing `*` amino acids from sequences, removes `-` characters, replaces internal `*`s and other redundant/non-standard amino acids with `X`, and converts sequences to uppercase.
2. removes duplicate sequence using a checksum, saving the mapping table to recover the duplicates at the end of the analysis.
3. Replace the names of the deduplicated sequences with a short simple one.
Basic usage:
```bash
predutils encode \
output.fasta \
output_mapping.tsv \
input_fastas/*
```
Note that it can take multiple input fasta files, and the filename is saved alongside the sequences in the output mapping table to recover that information.
By default, the temporary names will be `SR[A-Z0-9]5` e.g. `SR003AB`.
You can change the prefix (default `SR`) with the `--prefix` flag, and the number of id characters (default 5) with the `--length` parameter.
## `predutils split_fasta`
Splits a fasta files into several files each with a maximum of n sequences.
Basic usage:
```bash
predutils split_fasta --template 'chunk{index}.fasta' --size 100 in.fasta
```
The `--template` parameter accepts python `.format` style string formatting, and
is provided the variables `fname` (the input filename) and `index` (the chunk number starting at 1).
To pad the numbers with zeros for visual ordering in directories, use the something like `--template '{fname}.{index:0>4}.fasta'`.
Directories in the template will be created for you if they don't exist.
## `predutils precomputed`
Takes a database and some sequences and uses the sequence checksums to decide what has already been computed.
Outputs the precomputed results if `-o` is set.
Writes fasta for the remaining sequences to be computed.
The analyses and software versions to check for in the database are specified as a tab separated file to `analyses`.
```
usage: predutils precomputed [-h] [-o OUTFILE] [-t TEMPLATE] [--mem MEM] db analyses infasta
positional arguments:
db Where the sqlite database is
analyses A 3 column tsv file, no header. 'analysis<tab>software_version<tab>database_version'. database_version should be empty string if None.
infasta The fasta file to parse as input. Cannot be stdin.
optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the precomputed ldjson results to.
-t TEMPLATE, --template TEMPLATE
A template for the output filenames. Can use python `.format` style variable analysis. Directories will be created.
--mem MEM The amount of RAM in gibibytes to let SQLite use for cache.
```
## `predutils decode`
The other end of `predutils encode`.
Takes the common line delimited format from analyses and separates them back
out into the original filenames.
```bash
predutils decode [-h] [-t TEMPLATE] [--mem MEM] db map
positional arguments:
db Where the sqlite database is
map Where to save the id mapping file.
optional arguments:
-h, --help show this help message and exit
-t TEMPLATE, --template TEMPLATE
What to name the output files.
--mem MEM The amount of RAM in gibibytes to let SQLite use for cache.
predutils decode \
--template 'decoded/{filename}.ldjson' \
results.db \
output_mapping.tsv
```
We use the template flag to indicate what the filename output should be, using python format
style replacement. Available values to `--template` are `filename` and `filename_noext`.
The latter is just `filename` without the last extension.
## `predutils tables`
Take the common line delimited output from `predutils r2js` and recover a tabular version of the raw data.
Output filenames are controlled by the `--template` parameter, which uses python format style replacement.
Currently, `analysis` is the only value available to the template parameter.
Directories in the template will be created automatically.
```
predutils tables [-h] [-t TEMPLATE] [--mem MEM] db
positional arguments:
db Where to store the database
optional arguments:
-h, --help show this help message and exit
-t TEMPLATE, --template TEMPLATE
A template for the output filenames. Can use python `.format` style variable analysis. Directories will be created.
--mem MEM The amount of RAM in gibibytes to let SQLite use for cache.
predutils tables \
--template "my_sample-{analysis}.tsv" \
results.db
```
## `predutils gff`
Take the common line-delimited json output from `predutils r2js` and get a GFF3 formatted
set of results for analyses with a positional component (e.g. signal peptides, transmembrane domains, alignment results).
```
predutils gff \
--outfile "my_sample.gff3" \
results.ldjson
```
By default, mmseqs and HMMER search results will be filtered by the built in significance thresholds.
To include all matches in the output (and possibly filter by your own criterion) supply the flag `--keep-all`.
## `predutils rank`
Take a database of results entered by `load_db` and get a summary table
that includes all of the information commonly used for effector prediction, as well as
a scoring column to prioritise candidates.
```
predutils rank \
--outfile my_samples-ranked.tsv \
results.db
```
To change that Pfam or dbCAN domains that you consider to be predictive of effectors,
supply a text file with each pfam or dbcan entry on a new line (do not include pfam version number or `.hmm` in the ids) to the parameters `--dbcan` or `--pfam`.
You can also change the weights for how the score columns are calculated.
See `predutils rank --help` for a full list of parameters.
## `predutils regex`
```
predutils regex [-h] [-o OUTFILE] [-l] [-k {kex2_cutsite,rxlr_like_motif,custom}] [-r REGEX] INFILE
positional arguments:
INFILE The input fasta file.
optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the output to. Default: stdout
-l, --ldjson Write the output as ldjson rather than tsv.
-k {kex2_cutsite,rxlr_like_motif,custom}, --kind {kex2_cutsite,rxlr_like_motif,custom}
Which regular expressions to search for. If custom you must specify a regular expression to --regex. Default: custom.
-r REGEX, --regex REGEX
The regular expression to search for. Ignored if --kind is not custom.
```
## `predutils dump_db`
```
predutils dump_db [-h] [-o OUTFILE] [--mem MEM] db
positional arguments:
db The database to dump results from.
optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the output to. Default: stdout
--mem MEM The amount of RAM in gibibytes to let SQLite use for cache.
```
## `predutils map_to_genome`
This script projects the protein GFF file from the results into genome coordinates based on the GFF used to extract the proteins.
This is intended to support visualisation and selection of candidates in genome browsers like JBrowse or Apollo.
```
usage: predutils map_to_genome [-h] [-o OUTFILE] [--split {source,type}] [--no-filter-kex2] [--id ID_FIELD] genes annotations
positional arguments:
genes Gene GFF to use.
annotations Annotation GFF to use (i.e. the GFF3 output of predector)
options:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the output to. If using the --split parameter this
becomes the prefix. Default: stdout
--split {source,type}
Output distinct GFFs for each analysis or type of feature.
--no-filter-kex2 Output kex2 cutsites even if there is no signal peptide
--id ID_FIELD What GFF attribute field corresponds to your protein feature seqids?
Default uses the Parent field. Because some fields (like Parent)
can have multiple values, we'll raise an error if there is more
than 1 unique value. Any CDSs missing the specified
field (e.g. ID) will be skipped.
```
Pay attention to the `--id` parameter. This determines how the protein ID from the predector output will be matched to the genome GFF3.
By default it looks at the `Parent` attribute, as this is the default name from many GFF protein extraction tools.
But any attribute in the 9th column of the GFF can be used, e.g. to use the CDS feature `ID`, use `--id ID`.
This script will only consider records with type `CDS`, and matches names exactly (no partial matches).
`--split` provides a convenience function to split the GFFs into multiple GFFs based on type or analysis.
This is to facilitate loading the different features/analyses as separate tracks in the genome browser.
## `predutils score_to_genome`
This script plots numeric scores from the predector ranked table at the CDS coordinates from the GFF used to extract the proteins.
This is intended to support visualisation and selection of candidates from genome browsers like JBrowse or Apollo.
```
usage: predutils scores_to_genome [-h] [-o OUTFILE] [--target TARGET [TARGET ...]] \
[--id ID_FIELD] [--reducer {min,max,mean,median}] genes annotations
positional arguments:
genes Gene GFF to use.
annotations ranking table to use (i.e. the -ranked.tsv output of predector)
options:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the output to. Default: stdout
--target TARGET [TARGET ...]
Only output these columns into the bedgraph file.
By default writes a multi bedgraph with all columns.
--id ID_FIELD What GFF attribute field corresponds to your protein feature seqids?
Default uses the Parent field. Because some fields (like Parent)
can have multiple values, we'll raise an error if there is more
than 1 unique value. Any CDSs missing the specified
--reducer {min,max,mean,median}
How should we combine scores if two features overlap?
```
As with the `map_to_genome` command, you should ensure that the protein names (in the first column of the `-ranked.tsv` table), match with the attribute in the 9th column of the GFF3 file.
Because multiple CDS features can overlap (e.g. if there are alternative splicing patterns), we must combine those scores somehow so that a single value is associated with the genomic region.
This can be specified with the `--reducer` parameter which takes the maximum value by default (e.g. the highest effectorP score). But if instead you wanted the average use `--reducer mean`.
By default this script outputs a multi-bedgraph file with all numeric columns.
But if you only wish to output a subset of those columns, you can provide them as a space separated list to the `--target` parameter.
Note that an error will be raised if you try to access a non-numeric column.
If the `--target` parameter comes directly before the two positional arguments, you need to indicate where the space separated list stops with a `--`.
e.g.
```
predutils scores_go_genome --id ID --target effector_score apoplastp effectorp2 -- mygenes.gff3 mygenes-ranked.tsv
```
To split the output into single column bedgraphs you can use the following to extract one bedgraph per value column.
```
#!/usr/bin/env bash
set -euo pipefail
# OPTIONAL
# BGTOBW_EXE="bedGraphToBigWig" # This comes from the UCSC toolkit, or here: http://hgdownload.soe.ucsc.edu/admin/exe/
INFILE=$1
FAI=$2
PREFIX=$3
COLUMNS=( $(head -n 1 "${INFILE}" | cut -f4-) )
for i in "${!COLUMNS[@]}"
do
idx=$(( ${i} + 4 ))
col="${COLUMNS[${i}]}"
cut -f1,2,3,${idx} "${INFILE}" | tail -n+2 | awk '$4 != "NA"' > "${PREFIX}${col}.bedgraph"
# OPTIONAL
# ${BGTOBW_EXE} "${PREFIX}${col}.bedgraph" "${FAI}" "${PREFIX}${col}.bw"
done
```
This is useful for converting the tracks into bigwig files (which only support a single value), suitable for use with Jbrowse or Apollo.
## `predutils ipr_to_gff`
This program creates a GFF3 file in protein coordinates based on an InterProScan (5+) xml output file.
While interproscan _can_ output a GFF3 file of it's own, it doesn't include the domain names or InterPro/GO term annotations etc.
This program gives you a much richer output.
```
usage: predutils ipr_to_gff [-h] [-o OUTFILE] [--namespace NAMESPACE] xml
positional arguments:
xml Interproscan XML file.
optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the GFF output to. Default: stdout
```
## `predutils prot_to_genome`
This program is like `map_to_genome` but it doesn't do anything that is specialised to handling Predector output.
This _should_ be able to map any protein-coordinate GFF onto a genome, but it was developed to transfer interproscan results output by the `ipr_to_gff` tool.
```
usage: predutils prot_to_genome [-h] [-o OUTFILE] [--split] [--id ID_FIELD] genes annotations
positional arguments:
genes Gene GFF to use.
annotations Annotation GFF in protein coordinates
optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the output to. If using the --split parameter this becomes the prefix. Default: stdout
--split Output separate GFFs for each "source" in the GFF.
--id ID_FIELD What GFF attribute field corresponds to your protein feature seqids? Default uses the Parent field. Because some fields (like Parent) can have multiple values, we'll raise an error if there is more than 1 unique value. Any CDSs missing the specified
field (e.g. ID) will be skipped.
```
Note that we don't sort the output.
If you're using tools downstream that require a sorted file, e.g. TABIX, you can mix and match from the following.
This just happens to create suitable inputs for the GFF3+TABIX input type for Jbrowse.
```
FNAME="mapped.gff3"
(grep "^#" "${FNAME}"; grep -v "^#" "${FNAME}" | sort -k1,1 -k4,4n) | bgzip > "${FNAME}.gz"
bgzip --keep --reindex "${FNAME}.gz"
tabix -p gff "${FNAME}.gz"
```
%package help
Summary: Development documents and examples for predectorutils
Provides: python3-predectorutils-doc
%description help
# predector-utils
Utilities for running the predector pipeline.
This is where the models and more extensive utility scripts are developed.
All command line tools are accessible under the main command `predutils`.
## `predutils load_db`
Load a line-delimited JSON into an SQLite database.
Basic usage:
```bash
predutils load_db results.db results.ldjson
```
Options:
```
--replace-name
Replace record names with the string 'd'.
--drop-null-dbversion
Don't enter records requiring a database but have no database version specified.
--mem <float>
Use this much RAM for the SQLite cache. Set this to at most half of the total ram available.
--include ANALYSIS [ANALYSIS ...]
Only include these analyses, specify multiple with spaces.
--exclude ANALYSIS [ANALYSIS ...]
Exclude these analyses, specify multiple with spaces. Overrides analyses specified in --include.
```
If you are using this to set up a pre-computed database, specify the `--replace-name`, `--drop-null-dbversion` flags which will make sure any duplicate entries are excluded.
It is also recommended that you exclude results that are faster to recompute than to enter and fetch from the database, including `pepstats`, `kex2_cutsite`, and `rxlr_like_motif`.
This will be relatively fast for small to medium datasets, but can take several hours for many millions of entries.
Setting the `--mem` option is also a good idea to speed up inserting larger datasets.
## `predutils r2js`
Convert the output of one of the analyses into a common [line delimited JSON](http://ndjson.org/) format.
The json records retain all information from the original output files, but are much easier to parse because each line is just JSON.
Basic usage:
```bash
predutils r2js \
-o outfile.ldjson \
--software-version 1.0 \
--database-version 1.0 \
--pipeline-version 0.0.1 \
pfamscan \
pfamscan_results.txt \
in.fasta
```
Analyses available to parse in place of `pfamscan` are:
`signalp3_nn`, `signalp3_hmm`, `signalp4`, `signalp5`, `deepsig`, `phobius`, `tmhmm`,
`deeploc`, `targetp_plant` (v2), `targetp_non_plant` (v2), `effectorp1`, `effectorp2`,
`apoplastp`, `localizer`, `pfamscan`, `dbcan` (HMMER3 domtab output), `phibase` \*, `pepstats`,
`effectordb`, `kex2_cutsite`, and `rxlr_like_motif`.
\* assumes search with MMseqs with tab delimited output format columns: query, target, qstart, qend, qlen, tstart, tend, tlen, evalue, gapopen, pident, alnlen, raw, bits, cigar, mismatch, qcov, tcov.
## `predutils encode`
Preprocess some fasta files.
1. Strips trailing `*` amino acids from sequences, removes `-` characters, replaces internal `*`s and other redundant/non-standard amino acids with `X`, and converts sequences to uppercase.
2. removes duplicate sequence using a checksum, saving the mapping table to recover the duplicates at the end of the analysis.
3. Replace the names of the deduplicated sequences with a short simple one.
Basic usage:
```bash
predutils encode \
output.fasta \
output_mapping.tsv \
input_fastas/*
```
Note that it can take multiple input fasta files, and the filename is saved alongside the sequences in the output mapping table to recover that information.
By default, the temporary names will be `SR[A-Z0-9]5` e.g. `SR003AB`.
You can change the prefix (default `SR`) with the `--prefix` flag, and the number of id characters (default 5) with the `--length` parameter.
## `predutils split_fasta`
Splits a fasta files into several files each with a maximum of n sequences.
Basic usage:
```bash
predutils split_fasta --template 'chunk{index}.fasta' --size 100 in.fasta
```
The `--template` parameter accepts python `.format` style string formatting, and
is provided the variables `fname` (the input filename) and `index` (the chunk number starting at 1).
To pad the numbers with zeros for visual ordering in directories, use the something like `--template '{fname}.{index:0>4}.fasta'`.
Directories in the template will be created for you if they don't exist.
## `predutils precomputed`
Takes a database and some sequences and uses the sequence checksums to decide what has already been computed.
Outputs the precomputed results if `-o` is set.
Writes fasta for the remaining sequences to be computed.
The analyses and software versions to check for in the database are specified as a tab separated file to `analyses`.
```
usage: predutils precomputed [-h] [-o OUTFILE] [-t TEMPLATE] [--mem MEM] db analyses infasta
positional arguments:
db Where the sqlite database is
analyses A 3 column tsv file, no header. 'analysis<tab>software_version<tab>database_version'. database_version should be empty string if None.
infasta The fasta file to parse as input. Cannot be stdin.
optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the precomputed ldjson results to.
-t TEMPLATE, --template TEMPLATE
A template for the output filenames. Can use python `.format` style variable analysis. Directories will be created.
--mem MEM The amount of RAM in gibibytes to let SQLite use for cache.
```
## `predutils decode`
The other end of `predutils encode`.
Takes the common line delimited format from analyses and separates them back
out into the original filenames.
```bash
predutils decode [-h] [-t TEMPLATE] [--mem MEM] db map
positional arguments:
db Where the sqlite database is
map Where to save the id mapping file.
optional arguments:
-h, --help show this help message and exit
-t TEMPLATE, --template TEMPLATE
What to name the output files.
--mem MEM The amount of RAM in gibibytes to let SQLite use for cache.
predutils decode \
--template 'decoded/{filename}.ldjson' \
results.db \
output_mapping.tsv
```
We use the template flag to indicate what the filename output should be, using python format
style replacement. Available values to `--template` are `filename` and `filename_noext`.
The latter is just `filename` without the last extension.
## `predutils tables`
Take the common line delimited output from `predutils r2js` and recover a tabular version of the raw data.
Output filenames are controlled by the `--template` parameter, which uses python format style replacement.
Currently, `analysis` is the only value available to the template parameter.
Directories in the template will be created automatically.
```
predutils tables [-h] [-t TEMPLATE] [--mem MEM] db
positional arguments:
db Where to store the database
optional arguments:
-h, --help show this help message and exit
-t TEMPLATE, --template TEMPLATE
A template for the output filenames. Can use python `.format` style variable analysis. Directories will be created.
--mem MEM The amount of RAM in gibibytes to let SQLite use for cache.
predutils tables \
--template "my_sample-{analysis}.tsv" \
results.db
```
## `predutils gff`
Take the common line-delimited json output from `predutils r2js` and get a GFF3 formatted
set of results for analyses with a positional component (e.g. signal peptides, transmembrane domains, alignment results).
```
predutils gff \
--outfile "my_sample.gff3" \
results.ldjson
```
By default, mmseqs and HMMER search results will be filtered by the built in significance thresholds.
To include all matches in the output (and possibly filter by your own criterion) supply the flag `--keep-all`.
## `predutils rank`
Take a database of results entered by `load_db` and get a summary table
that includes all of the information commonly used for effector prediction, as well as
a scoring column to prioritise candidates.
```
predutils rank \
--outfile my_samples-ranked.tsv \
results.db
```
To change that Pfam or dbCAN domains that you consider to be predictive of effectors,
supply a text file with each pfam or dbcan entry on a new line (do not include pfam version number or `.hmm` in the ids) to the parameters `--dbcan` or `--pfam`.
You can also change the weights for how the score columns are calculated.
See `predutils rank --help` for a full list of parameters.
## `predutils regex`
```
predutils regex [-h] [-o OUTFILE] [-l] [-k {kex2_cutsite,rxlr_like_motif,custom}] [-r REGEX] INFILE
positional arguments:
INFILE The input fasta file.
optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the output to. Default: stdout
-l, --ldjson Write the output as ldjson rather than tsv.
-k {kex2_cutsite,rxlr_like_motif,custom}, --kind {kex2_cutsite,rxlr_like_motif,custom}
Which regular expressions to search for. If custom you must specify a regular expression to --regex. Default: custom.
-r REGEX, --regex REGEX
The regular expression to search for. Ignored if --kind is not custom.
```
## `predutils dump_db`
```
predutils dump_db [-h] [-o OUTFILE] [--mem MEM] db
positional arguments:
db The database to dump results from.
optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the output to. Default: stdout
--mem MEM The amount of RAM in gibibytes to let SQLite use for cache.
```
## `predutils map_to_genome`
This script projects the protein GFF file from the results into genome coordinates based on the GFF used to extract the proteins.
This is intended to support visualisation and selection of candidates in genome browsers like JBrowse or Apollo.
```
usage: predutils map_to_genome [-h] [-o OUTFILE] [--split {source,type}] [--no-filter-kex2] [--id ID_FIELD] genes annotations
positional arguments:
genes Gene GFF to use.
annotations Annotation GFF to use (i.e. the GFF3 output of predector)
options:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the output to. If using the --split parameter this
becomes the prefix. Default: stdout
--split {source,type}
Output distinct GFFs for each analysis or type of feature.
--no-filter-kex2 Output kex2 cutsites even if there is no signal peptide
--id ID_FIELD What GFF attribute field corresponds to your protein feature seqids?
Default uses the Parent field. Because some fields (like Parent)
can have multiple values, we'll raise an error if there is more
than 1 unique value. Any CDSs missing the specified
field (e.g. ID) will be skipped.
```
Pay attention to the `--id` parameter. This determines how the protein ID from the predector output will be matched to the genome GFF3.
By default it looks at the `Parent` attribute, as this is the default name from many GFF protein extraction tools.
But any attribute in the 9th column of the GFF can be used, e.g. to use the CDS feature `ID`, use `--id ID`.
This script will only consider records with type `CDS`, and matches names exactly (no partial matches).
`--split` provides a convenience function to split the GFFs into multiple GFFs based on type or analysis.
This is to facilitate loading the different features/analyses as separate tracks in the genome browser.
## `predutils score_to_genome`
This script plots numeric scores from the predector ranked table at the CDS coordinates from the GFF used to extract the proteins.
This is intended to support visualisation and selection of candidates from genome browsers like JBrowse or Apollo.
```
usage: predutils scores_to_genome [-h] [-o OUTFILE] [--target TARGET [TARGET ...]] \
[--id ID_FIELD] [--reducer {min,max,mean,median}] genes annotations
positional arguments:
genes Gene GFF to use.
annotations ranking table to use (i.e. the -ranked.tsv output of predector)
options:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the output to. Default: stdout
--target TARGET [TARGET ...]
Only output these columns into the bedgraph file.
By default writes a multi bedgraph with all columns.
--id ID_FIELD What GFF attribute field corresponds to your protein feature seqids?
Default uses the Parent field. Because some fields (like Parent)
can have multiple values, we'll raise an error if there is more
than 1 unique value. Any CDSs missing the specified
--reducer {min,max,mean,median}
How should we combine scores if two features overlap?
```
As with the `map_to_genome` command, you should ensure that the protein names (in the first column of the `-ranked.tsv` table), match with the attribute in the 9th column of the GFF3 file.
Because multiple CDS features can overlap (e.g. if there are alternative splicing patterns), we must combine those scores somehow so that a single value is associated with the genomic region.
This can be specified with the `--reducer` parameter which takes the maximum value by default (e.g. the highest effectorP score). But if instead you wanted the average use `--reducer mean`.
By default this script outputs a multi-bedgraph file with all numeric columns.
But if you only wish to output a subset of those columns, you can provide them as a space separated list to the `--target` parameter.
Note that an error will be raised if you try to access a non-numeric column.
If the `--target` parameter comes directly before the two positional arguments, you need to indicate where the space separated list stops with a `--`.
e.g.
```
predutils scores_go_genome --id ID --target effector_score apoplastp effectorp2 -- mygenes.gff3 mygenes-ranked.tsv
```
To split the output into single column bedgraphs you can use the following to extract one bedgraph per value column.
```
#!/usr/bin/env bash
set -euo pipefail
# OPTIONAL
# BGTOBW_EXE="bedGraphToBigWig" # This comes from the UCSC toolkit, or here: http://hgdownload.soe.ucsc.edu/admin/exe/
INFILE=$1
FAI=$2
PREFIX=$3
COLUMNS=( $(head -n 1 "${INFILE}" | cut -f4-) )
for i in "${!COLUMNS[@]}"
do
idx=$(( ${i} + 4 ))
col="${COLUMNS[${i}]}"
cut -f1,2,3,${idx} "${INFILE}" | tail -n+2 | awk '$4 != "NA"' > "${PREFIX}${col}.bedgraph"
# OPTIONAL
# ${BGTOBW_EXE} "${PREFIX}${col}.bedgraph" "${FAI}" "${PREFIX}${col}.bw"
done
```
This is useful for converting the tracks into bigwig files (which only support a single value), suitable for use with Jbrowse or Apollo.
## `predutils ipr_to_gff`
This program creates a GFF3 file in protein coordinates based on an InterProScan (5+) xml output file.
While interproscan _can_ output a GFF3 file of it's own, it doesn't include the domain names or InterPro/GO term annotations etc.
This program gives you a much richer output.
```
usage: predutils ipr_to_gff [-h] [-o OUTFILE] [--namespace NAMESPACE] xml
positional arguments:
xml Interproscan XML file.
optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the GFF output to. Default: stdout
```
## `predutils prot_to_genome`
This program is like `map_to_genome` but it doesn't do anything that is specialised to handling Predector output.
This _should_ be able to map any protein-coordinate GFF onto a genome, but it was developed to transfer interproscan results output by the `ipr_to_gff` tool.
```
usage: predutils prot_to_genome [-h] [-o OUTFILE] [--split] [--id ID_FIELD] genes annotations
positional arguments:
genes Gene GFF to use.
annotations Annotation GFF in protein coordinates
optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --outfile OUTFILE
Where to write the output to. If using the --split parameter this becomes the prefix. Default: stdout
--split Output separate GFFs for each "source" in the GFF.
--id ID_FIELD What GFF attribute field corresponds to your protein feature seqids? Default uses the Parent field. Because some fields (like Parent) can have multiple values, we'll raise an error if there is more than 1 unique value. Any CDSs missing the specified
field (e.g. ID) will be skipped.
```
Note that we don't sort the output.
If you're using tools downstream that require a sorted file, e.g. TABIX, you can mix and match from the following.
This just happens to create suitable inputs for the GFF3+TABIX input type for Jbrowse.
```
FNAME="mapped.gff3"
(grep "^#" "${FNAME}"; grep -v "^#" "${FNAME}" | sort -k1,1 -k4,4n) | bgzip > "${FNAME}.gz"
bgzip --keep --reindex "${FNAME}.gz"
tabix -p gff "${FNAME}.gz"
```
%prep
%autosetup -n predectorutils-0.9.1
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-predectorutils -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Wed May 31 2023 Python_Bot <Python_Bot@openeuler.org> - 0.9.1-1
- Package Spec generated
|