-
Notifications
You must be signed in to change notification settings - Fork 1
/
PlantClusterFinder.asv
4568 lines (4413 loc) · 235 KB
/
PlantClusterFinder.asv
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% PlantClusterFinder 1.3
% PlantClusterFinder (PCF) detects metabolic gene clusters in a sequenced
% genome. It uses a gene location file provided by the user (see below) and
% a PGDB created with Pathway Tools as well as further information (see
% below) to identify enzyme-coding genes (metabolic genes) located together
% on a chromosome. Initially only continous stretches of metabolic genes
% lying directly next to each other are allowed. This condition is relaxed
% by iteratively increasing the intervening (non-metabolic) gene size by
% one. Several criteria to select for clusters are provided. In addition to
% this, clusters can be prevented from forming by a section of criteria.
% Details of PCF (version 1.0) can be found in PMID: 28228535.
%
% The major differences between this version (1.3) and previous versions
% (1.0 and 1.2) are:
%
% 1) Physical breaks of the genome or sequencing gaps of unknown size are
% typically encoded by stretches of Ns in the genome assembly fasta
% file. Previously we inserted N hypothetical genes. This however
% diluted the background of low quality genomes with non-enzymes, and
% hence the likelyhood of a cluster to be classified as top x% of
% enzyme dense regions was better than in a genome that had good
% quality. In version 1.3 we identify these breaks and prevent
% formation of a cluster over these gaps.
% 2) Any sequencing information that is missing is typically hard masked
% with Ns. Previously, any intergenic region affected by at least one
% N was evaluated for its length, and hypothetical genes were inserted
% accordingly (See Schlapfer et al, PMID: 28228535). This led
% sometimes to unrealistic prevention of detecting gene clusters. It
% is unlikely that missing information about a single nucleotide would
% (if it would be known) lead to the finding of multiple gene models.
% Thus here we changed the code to insert 2 hypothetical genes only if
% a strech of unknown sequence is larger than nth percentile of gene
% sequences (set to 5). We also provide the option to NOT insert any
% hypothetical genes all together. Instead we by default we use
% MaxSeqGapSize set to 100000 and MaxInterGeneDistByMedian set to 50
% resulting in similar clusters as in PCF version 1.0.
% 3) Large gene poor intergenic regions are present in genomes. In this
% version we provide the option of several parameters to prevent
% clusters from spanning such large gene poor regions.
%
% Authors: Pascal Schlapfer, December 2017
% Bo Xue, December 2017
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Mandatory inputs: all files need full path, order does not matter.
%
% -pgdb fullpath: Give full path of PGDB flat file folder, where the
% flat files of the species pgdb is stored.
% -rmdf fullpath: TSV file of the metabolic domains of reactions. Check
% if file is outdated (needs to contain all reactions
% that are present in the PGDB that have genes
% annotated to).
% -md list: A list of Metabolic domains that should be analyzed. For
% example {'Amines and Polyamines Metabolism'; 'Amino Acids
% Metabolism'}
% -psf fullpath: Protein sequence file of the genome. Can only contain
% Protein IDs as header e.g. >protein1-ID
% -gtpf fullpath: TSV file with a header describing gene, transcript,
% and protein identifier and then for all the
% identfiers the listings (gene-ID, transcript-ID,
% protein-ID). This is used to map information
% regarding transcripts (currently not used) and
% proteins (used for MCL clustering, potentially also
% used in PGDBs) to the genes (e.g. the gene location
% information).
% -glof fullpath: TSV file with gene ID, start bp, end bp, chromosome /
% scaffold, strand (encoded as 1 or -1). This file can
% be generated with a biomart or out of a gff3 file.
% -dnaf fullpath: Fasta file of the HARDMASKED genome nucleotide
% sequences.
% -sitf fullpath: TSV file describing the classes of enzymes that
% should be classified as signature or tailoring
% enzymes to identify clusters containing such.
% -gout fullpath: Path and file name to the gene-Outputfile, make sure
% you have access to the file and folder. This is the
% first results output file that will be generated.
% -cout fullpath: Path and file name to the cluster-Outputfile, make
% sure you have access to the file and folder. This is
% the second Results output file that will be
% generated.
%
% Optional Inputs:
% 'GenesDat_GeneInfo': needs to be followed by a list of Attributes in
% genes.dat. Defines where gene ID information
% should be searched for. Default is 'Unique-ID',
% 'Accession-1', 'Accession-2'
% 'MCLClusterFile': needs to be followed by either 1 or 0. With a default
% of 0. 1 indicates that the input file is not a
% protein fasta file, but a precomputed MCL
% clustering file (precomputing can be usefull for
% speed). If such a file is used, then nothing but
% gene IDs and tabs and new lines are allowed in this
% file.
% 'HypoGenePercentile': needs to be followed by a number. Defines the
% length of sequencing gap that should be
% populated by two hypothetical genes. If this is
% 10, then two hypothetical genes are introduced
% as soon as the sequencing gap exceeds the
% (100-10) lower percentile of the background
% size of all genes of the genome (default is 5).
% 'MaxSeqGapSize': needs to be followed by a number. Maximal masked
% nucleotide region (in bp) that a cluster is allowed
% to bridge (default is 100000).
% 'MaxInterGeneDist': needs to be followed by a number. Maximal
% intergenic distance ( in bp) that still can be
% crossed by a gene cluster. (default is -1, thus
% inactive).
% 'MaxInterGeneDistByMedian': needs to be followed by a number. Maximal
% intergenic distance that still can be
% crossed by a gene cluster, here defined
% by this number times the median of the
% gene sizes. (default is 50. Set it to -1
% if it should be inactive).
% 'PercentileForMaxInterGeneDist': needs to be followed by a number.
% Calculates the maximal intergenic
% distance that still can be crossed
% by a gene cluster. This number
% determines the percentile to choose
% from all the distances. If this is
% 99.9, then a cluster is allowed to
% bridge if the largest intergenic
% distance in the cluster is below
% 99.9% of the background size of all
% intergenic distances of the genome
% (default is -1, thus inactive).
% 'SeqGapSizesChromBreak': needs to be followed by a list of numbers.
% The masked nucleotides sequences of these
% specific lengths will prevent cluster
% formation (Default is an empty list: []).
% 'PreScreenGaps': needs to be followed by either 1 or zero. Defines if
% sequencing gaps should be prescreened to delete them
% if they are anyway too small to matter. (default is
% 0)
% 'OverwriteSeqGapInfo': needs to be followed by either 1 or 0. Forces
% masked nucleotide analysis for finding
% sequencing gaps (default is 0, no
% enforcement).
% 'OverwriteMCLClustering': needs to be followed by either 1 or 0.
% Forces (if set to 1) that the MCL
% clustering is redone even if the result
% files are already present (default is 0).
% 'Verbose': needs to be followed by a number (0 is default, 1 gives
% more screen-output, 2 gives exhaustive screen-output).
% 'EnzMinForClusters': needs to be followed by a number: Defines the
% minimum number of enyzmes that need to be
% present in a cluster (default is 3).
% 'KbRangeLD': needs to be followed by a number. Genes that are
% separated by more than this size (in bp) are not
% considered as local duplicates. (default is 100000)
% 'GeneRangeLD': needs to be followed by a number. Number of
% intervening genes that are allowed to separate two
% local duplicated genes. Two genes that are separated
% by more than this many intervening genes are not
% called local duplicates. (default is 10)
% 'TopPercentClusters': needs to be followed by a number. Clusters are
% labeled if they are within this top X% of
% enzyme dense clusters compared to the
% background. (default is 5)
% 'MinStepSize': needs to be followed by a number. Minimal intervening
% gene size that should be computed (default is 5).
% 'MaxStepSize': needs to be followed by a number. Maximal intervening
% gene size that should be computed (default is 20).
% 'Criterion': needs to be followed by a number. Criterion after which
% stepsize (intervening gene size) is chosen (default is
% 2).
% 1: as published in Schlapfer et al 2017 (PMID:28228535)
% sum(enzymes in clusters) - sum(non-enzymes in clusters) > 0.
% 2: stepsize 3 (because most organisms take this one)
% 3: sum(enzymes in clusters) - sum(non-enzymes in clusters, without hypo genes) -2*sum(hypogenes)
% 4: sum(clusters in stepsize n) > sum(clusters in stepsize n+1).
% -help: Display help
% -para: needs to be followed by a number: how many cpus can be used by
% the algorithm (used for MCL clustering and Sequencing gap
% search). The default is 1.
% 'UnmaskedDNA': needs to be followed by a number. Defines if plant
% Cluster finder should continue despite a non-masked
% genome sequence file was used (default is 0, not
% continue).
% 'PGDBIdsToMap': needs to be followed by a string. Can contain the
% Letters G and/or T and/or P. In that case (the pgdb
% is mapped to Gene (G) and/or Transcript (T) and/or
% Protein (P) Ids of the Gene conversion file. The
% default value is 'G'.
% 'RunAfterPart': Needs to be followed by a number. Sets the parts of
% the algorithm that should be recomputed. (default is
% 0)
% 'Tempsaves': Defines if Temporary saves should be made. (default is
% 0)
% 'TempsavesOverwrite': Defines if Temporary saves should be
% overwritten. (Default is 0).
% 'RemoveNonProtLocations': Defines if the protein-fasta file should be
% used to clean out the gene position file
% from sequences that do not show up on the
% protein fasta file, and thus do not have
% had a chance to be predicted to be an
% enzyme. (Default 0)
% 'InsertHypos': needs to be followed by 0 or 1 (can be extended with
% code). Defines if the genome should be populated by
% hypothetical genes in sequencing gaps that are not
% physical breaks. (Default 0)
% 'HypoAmount': needs to be followed by a number. Defines by how many
% hypothetical genes a sequencing gap that is not a
% physical break should be populated by artificial genes
% to punish such sequencing gaps from becoming clusters.
% (Default 0)
% 'OutputType': Defines the format of the Outputfiles: 'old' is using
% the old format to report all clusters of all stepsizes,
% 'verbose' defines that top percent clusters of all
% stepsizes are reported. 'simple' just reports the top
% percent clusters of the chosen stepsize (default
% simple).
%
% Outputs:
% None (Two files are generated: vGeneOutputFile, containing all the
% information about genes and vClusterOutputFile, containing all
% the information about clusters)
%
% USAGE:
%
% MATLAB (paths with windows, please be aware that certain parts need
% to be run in linux!):
% PlantClusterFinder('-pgdb', vPGDB_FlatFileFolder, '-rmdf', ...
% vMD_reactions_File, '-md', ...
% vMD_to_annotate, '-psf', ...
% vProtein_sequence_FastaFile, '-gtpf', ...
% vGeneTranscriptProtein_mapping_File, ...
% '-glof', vGeneLocation_File, '-dnaf', ...
% vDNA_FastaFile, '-sitf', ...
% vSignatureTailorFile, '-gout', ...
% vGeneOutputFile, '-cout', ...
% vClusterOutputFile, varargin)
%
% Example: (use absolute paths!)
% PlantClusterFinder('-pgdb', '[PlantClusterFinder]\csubellipsoidea\pgdb\csubellipsoideacyc\1.0\data\', ...
% '-rmdf', '[PlantClusterFinder]\Inputs\ReactionMetabolicDomainClassification.txt', ...
% '-md', {'Amines and Polyamines Metabolism'; 'Amino Acids Metabolism'; 'Carbohydrates Metabolism'; 'Cofactors Metabolism'; 'Detoxification Metabolism'; 'Energy Metabolism'; 'Fatty Acids and Lipids Metabolism'; 'Hormones Metabolism'; 'Inorganic Nutrients Metabolism'; 'Nitrogen-Containing Compounds'; 'Nucleotides Metabolism'; 'Phenylpropanoid Derivatives'; 'Polyketides'; 'Primary-Specialized Interface Metabolism'; 'Redox Metabolism'; 'Specialized Metabolism'; 'Sugar Derivatives'; 'Terpenoids'}, ...
% '-psf', '[PlantClusterFinder]\csubellipsoidea\CsubellipsoideaC_169_227_v2.0.protein.pcf13.fa', ...
% '-gtpf', '[PlantClusterFinder]\csubellipsoidea\gtpf_CsubellipsoideaC_169_227_v2.0.annotation_info.txt.txt', ...
% '-glof', '[PlantClusterFinder]\csubellipsoidea\glof_CsubellipsoideaC_169_227_v2.0.gene.gff3.txt', ...
% '-dnaf', '[PlantClusterFinder]\csubellipsoidea\CsubellipsoideaC_169_227_v2.0.hardmasked.fa', ...
% '-sitf', '[PlantClusterFinder]\Inputs\scaffold-tailoring-reactions-05082016.tab', ...
% '-gout', '[PlantClusterFinder]\csubellipsoidea\csubellipsoidea_Gene_v1_3.txt', ...
% '-cout', '[PlantClusterFinder]\csubellipsoidea\csubellipsoidea_Clust_v1_3.txt', ...
% 'SeqGapSizesChromBreak', [10000], 'PGDBIdsToMap', 'GTP');
% % Note, PGDBIdsToMap is only needed here because the pgdb
% % contains protein Ids in place of gene identifiers.
%
% Shell, standalone (linux, but you can compile a windows version, see
% how to compile new version file):
% To use standalone, download matlab runtime from matlab website.
% Make sure, you download the v91. Then replace
% "/share/apps/MATLAB/MATLAB_Runtime/v91" int the example with your
% path to your runtime.
%
% USE ABSOLUTE PATHS!
%
% ./run_PlantClusterFinder.sh /share/apps/MATLAB/MATLAB_Runtime/v91 -pgdb "./csubellipsoidea/pgdb/csubellipsoideacyc/1.0/data/" -rmdf "./Inputs/ReactionMetabolicDomainClassification.txt" -md "{'Amines and Polyamines Metabolism'; 'Amino Acids Metabolism'; 'Carbohydrates Metabolism'; 'Cofactors Metabolism'; 'Detoxification Metabolism'; 'Energy Metabolism'; 'Fatty Acids and Lipids Metabolism'; 'Hormones Metabolism'; 'Inorganic Nutrients Metabolism'; 'Nitrogen-Containing Compounds'; 'Nucleotides Metabolism'; 'Phenylpropanoid Derivatives'; 'Polyketides'; 'Primary-Specialized Interface Metabolism'; 'Redox Metabolism'; 'Specialized Metabolism'; 'Sugar Derivatives'; 'Terpenoids'}" -psf "./csubellipsoidea/CsubellipsoideaC_169_227_v2.0.protein.pcf13.fa" -gtpf "./csubellipsoidea/gtpf_CsubellipsoideaC_169_227_v2.0.annotation_info.txt.txt" -glof "./csubellipsoidea/glof_CsubellipsoideaC_169_227_v2.0.gene.gff3.txt" -dnaf "./csubellipsoidea/CsubellipsoideaC_169_227_v2.0.hardmasked.fa" -sitf "./Inputs/scaffold-tailoring-reactions-05082016.tab" -gout "./csubellipsoidea/csubellipsoidea_Gene1_3.txt" -cout "./csubellipsoidea/csubellipsoidea_Clust1_3.txt" SeqGapSizesChromBreak '[10000]' PGDBIdsToMap GTP
% % Note, PGDBIdsToMap is only needed here because the pgdb
% % contains protein Ids in place of gene identifiers.
%
function PlantClusterFinder(varargin)
%% Display help if no arguments
if nargin == 0
f_display_help()
return;
end
%% Display parameters:
if ispc()
vc = 1;
for vi = 1:size(varargin,2)
if vc == 1
fprintf('Parameter %i: %s\n', (vi-1)/2+1, varargin{1,vi})
vc = vc + 1;
else
if ischar(varargin{1,vi})
fprintf('Value: %s\n', varargin{1,vi});
vc = 1;
elseif isnumeric(varargin{1,vi})
fprintf('Value: %i\n', varargin{1,vi});
vc = 1;
else
fprintf('Value: can not be displayed\n');
vc = 1;
end
end
end
else
vc = 1;
for vi = 1:size(varargin,2)
if vc == 1
fprintf('Parameter %i: %s\n', (vi-1)/2+1, varargin{1,vi})
vc = vc + 1;
else
fprintf('Value: %s\n', varargin{1,vi})
vc = 1;
end
end
end
%% Initializing parameters
fprintf('Initializing parameters and running PlantClusterFinder\n');
vVerbose = 0;
vCurrArgin = 0;
vGenesDat_GeneInfo = {'Unique-ID', 'Accession-1', 'Accession-2'};
vMCLClusterFile = 0;
vHypoGenePercentile = 5;
vMaxSeqGapSize = 100000;
vMaxInterGeneDist = -1;
vMaxInterGeneDistByMedian = 50;
vPercentileForMaxInterGeneDist = -1;
vSeqGapSizesChromBreak = [];
vPreScreenGaps = 0;
vMinStepSize = 5;
vMaxStepSize = 20;
vCriterion = 2;
vTopPercentClusters = 5;
vOverwriteSeqGapInfo = 0;
vOverwriteMCLClustering = 0;
vKbRangeLD = 100000;
vGeneRangeLD = 10;
vEnzMinForClusters = 3;
vPara = 1;
vUnmaskedDNA = 0;
vPGDBIdsToMap = 'G';
vPartFinished = -1;
vRunAfterPart = 0;
vTempsaves = 0;
vTempsavesOverwrite = 0;
vRemoveNonProtLocations = 0;
vInsertHypos = 0;
vOutputType = 'simple';
if vPartFinished < 0
if nargin > vCurrArgin
vi = 1;
while vi <= nargin - vCurrArgin
if ischar(varargin{1,vi})
if strcmp(varargin{1,vi},'-pgdb')
if ischar(varargin{1,vi + 1})
vPGDB_FlatFileFolder = varargin{1,vi + 1};
if ~ispc()
if isempty(regexp(vPGDB_FlatFileFolder,'/$','once'))
vPGDB_FlatFileFolder = [vPGDB_FlatFileFolder '/']; %#ok<*AGROW>
end
else
if isempty(regexp(vPGDB_FlatFileFolder,'\\$','once'))
vPGDB_FlatFileFolder = [vPGDB_FlatFileFolder '\'];
end
end
else
error('PGDB Flatfilefolder argument is not of type string\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'-rmdf')
if ischar(varargin{1,vi + 1})
vMD_reactions_File = varargin{1,vi + 1};
else
error('MD file for reactions argument is not of type string\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'-md')
if ischar(varargin{1,vi + 1})
eval(['vMD_to_annotate =' ' ' varargin{1,vi + 1} ';']);
elseif iscell(varargin{1,vi + 1})
vMD_to_annotate = varargin{1,vi + 1};
else
error('Metabolic domains to annotate list argument is not of type string\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'-psf')
if ischar(varargin{1,vi + 1})
vProtein_sequence_FastaFile = varargin{1,vi + 1};
else
error('Protein sequence file argument is not of type string\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'-gtpf')
if ischar(varargin{1,vi + 1})
vGeneTranscriptProtein_mapping_File = varargin{1,vi + 1};
else
error('Gene transcript protein id conversion file argument is not of type string\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'-glof')
if ischar(varargin{1,vi + 1})
vGeneLocation_File = varargin{1,vi + 1};
else
error('Gene location (postion) file argument is not of type string\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'-dnaf')
if ischar(varargin{1,vi + 1})
vDNA_FastaFile = varargin{1,vi + 1};
else
error('Masked dna fasta file argument is not of type string\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'-sitf')
if ischar(varargin{1,vi + 1})
vSignatureTailorFile = varargin{1,vi + 1};
else
error('Signature and tailoring reacitons file argument is not of type string\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'-gout')
if ischar(varargin{1,vi + 1})
vGeneOutputFile = varargin{1,vi + 1};
else
error('Outputfile for gene summary argument is not of type string\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'-cout')
if ischar(varargin{1,vi + 1})
vClusterOutputFile = varargin{1,vi + 1};
else
error('Outputfile for cluster summary argument is not of type string\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'GenesDat_GeneInfo')
if ischar(varargin{1,vi + 1})
eval(['vGenesDat_GeneInfo = ' varargin{1,vi + 1} ';']);
elseif iscell(varargin{1,vi + 1})
vGenesDat_GeneInfo = varargin{1,vi + 1};
else
error('GenesDat_GeneInfo does not follow format {''Attribute1'', ''Atribute2''}\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'MCLClusterFile')
if ischar(varargin{1,vi + 1})
vMCLClusterFile = str2num(varargin{1,vi + 1}); %#ok<*ST2NM>
elseif isnumeric(varargin{1,vi + 1})
vMCLClusterFile = varargin{1,vi + 1};
else
error('MCLClusterFile is not followed by a number (either 1 or 0)\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'HypoGenePercentile')
if isnumeric(varargin{1,vi + 1})
vHypoGenePercentile = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vHypoGenePercentile = str2num(varargin{1,vi + 1});
else
error('HypoGenePercentile is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'MaxSeqGapSize')
if isnumeric(varargin{1,vi + 1})
vMaxSeqGapSize = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vMaxSeqGapSize = str2num(varargin{1,vi + 1});
else
error('MaxSeqGapSize is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'MaxInterGeneDist')
if isnumeric(varargin{1,vi + 1})
vMaxInterGeneDist = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vMaxInterGeneDist = str2num(varargin{1,vi + 1});
else
error('MaxInterGeneDist is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'MaxInterGeneDistByMedian')
if isnumeric(varargin{1,vi + 1})
vMaxInterGeneDistByMedian = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vMaxInterGeneDistByMedian = str2num(varargin{1,vi + 1});
else
error('MaxInterGeneDist is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'PercentileForMaxInterGeneDist')
if isnumeric(varargin{1,vi + 1})
vPercentileForMaxInterGeneDist = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vPercentileForMaxInterGeneDist = str2num(varargin{1,vi + 1});
else
error('PercentileForMaxInterGeneDist is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'SeqGapSizesChromBreak')
if isnumeric(varargin{1,vi + 1})
vSeqGapSizesChromBreak = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
if strcmp(varargin{1,vi + 1},'')
eval('vSeqGapSizesChromBreak = [];');
else
eval(['vSeqGapSizesChromBreak = ' varargin{1,vi + 1} ';']);
end
else
error('SeqGapSizesChromBreak does not follow format [Number1, Number2]\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'PreScreenGaps')
if isnumeric(varargin{1,vi + 1})
vPreScreenGaps = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vPreScreenGaps = str2num(varargin{1,vi + 1});
else
error('PreScreenGaps is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'OverwriteSeqGapInfo')
if isnumeric(varargin{1,vi + 1})
vOverwriteSeqGapInfo = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vOverwriteSeqGapInfo = str2num(varargin{1,vi + 1});
else
error('OverwriteSeqGapInfo is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'OverwriteMCLClustering')
if isnumeric(varargin{1,vi + 1})
vOverwriteMCLClustering = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vOverwriteMCLClustering = str2num(varargin{1,vi + 1});
else
error('OverwriteMCLClustering is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'Verbose')
if isnumeric(varargin{1,vi + 1})
vVerbose = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vVerbose = str2num(varargin{1,vi + 1});
else
error('Verbose is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'EnzMinForClusters')
if isnumeric(varargin{1,vi + 1})
vEnzMinForClusters = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vEnzMinForClusters = str2num(varargin{1,vi + 1});
else
error('EnzMinForClusters is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'KbRangeLD')
if isnumeric(varargin{1,vi + 1})
vKbRangeLD = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vKbRangeLD = str2num(varargin{1,vi + 1});
else
error('KbRangeLD is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'GeneRangeLD')
if isnumeric(varargin{1,vi + 1})
vGeneRangeLD = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vGeneRangeLD = str2num(varargin{1,vi + 1});
else
error('GeneRangeLD is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'TopPercentClusters')
if isnumeric(varargin{1,vi + 1})
vTopPercentClusters = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vTopPercentClusters = str2num(varargin{1,vi + 1});
else
error('TopPercentClusters is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'MinStepSize')
if isnumeric(varargin{1,vi + 1})
vMinStepSize = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vMinStepSize = str2num(varargin{1,vi + 1});
else
error('MinStepSize is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'MaxStepSize')
if isnumeric(varargin{1,vi + 1})
vMaxStepSize = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vMaxStepSize = str2num(varargin{1,vi + 1});
else
error('MaxStepSize is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'Criterion')
if isnumeric(varargin{1,vi + 1})
vCriterion = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vCriterion = str2num(varargin{1,vi + 1});
else
error('Criterion is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'-para')
if isnumeric(varargin{1,vi + 1})
vPara = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vPara = str2num(varargin{1,vi + 1});
else
error('-para is not followed by a string that can be converted into a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'help') || strcmp(varargin{1,vi},'h') || strcmp(varargin{1,vi},'man') || ...
strcmp(varargin{1,vi},'info') || strcmp(varargin{1,vi},'?') || strcmp(varargin{1,vi},'-help') ...
|| strcmp(varargin{1,vi},'-h') || strcmp(varargin{1,vi},'-info') || strcmp(varargin{1,vi},'-man') || strcmp(varargin{1,vi},'-?')
f_display_help()
return;
elseif strcmp(varargin{1,vi},'UnmaskedDNA')
if isnumeric(varargin{1,vi + 1})
vUnmaskedDNA = varargin{1,vi + 1};
elseif ischar(varargin{1,vi + 1})
vUnmaskedDNA = str2num(varargin{1,vi + 1});
else
error('UnmaskedDNA is not followed by a number\n');
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'PGDBIdsToMap')
if ~ischar(varargin{1,vi + 1})
error('UnmaskedDNA is not followed by a string\n');
else
vPGDBIdsToMap = varargin{1,vi + 1};
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'RunAfterPart')
if ~ischar(varargin{1,vi + 1}) && ~isnumeric(varargin{1,vi + 1})
error('RunAfterPart is not followed by a string\n');
elseif ischar(varargin{1,vi + 1})
vRunAfterPart = str2num(varargin{1,vi + 1});
elseif isnumeric(varargin{1,vi + 1})
vRunAfterPart = varargin{1,vi + 1};
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'Tempsaves')
if ~ischar(varargin{1,vi + 1}) && ~isnumeric(varargin{1,vi + 1})
error('Tempsaves is not followed by a string\n');
elseif ischar(varargin{1,vi + 1})
vTempsaves = str2num(varargin{1,vi + 1});
elseif isnumeric(varargin{1,vi + 1})
vTempsaves = varargin{1,vi + 1};
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'TempsavesOverwrite')
if ~ischar(varargin{1,vi + 1}) && ~isnumeric(varargin{1,vi + 1})
error('TempsavesOverwrite is not followed by a string\n');
elseif ischar(varargin{1,vi + 1})
vTempsavesOverwrite = str2num(varargin{1,vi + 1});
elseif isnumeric(varargin{1,vi + 1})
vTempsavesOverwrite = varargin{1,vi + 1};
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'RemoveNonProtLocations')
if ~ischar(varargin{1,vi + 1}) && ~isnumeric(varargin{1,vi + 1})
error('RemoveNonProtLocations is not followed by a string\n');
elseif ischar(varargin{1,vi + 1})
vRemoveNonProtLocations = str2num(varargin{1,vi + 1});
elseif isnumeric(varargin{1,vi + 1})
vRemoveNonProtLocations = varargin{1,vi + 1};
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'InsertHypos')
if ~ischar(varargin{1,vi + 1}) && ~isnumeric(varargin{1,vi + 1})
error('InsertHypos is not followed by a string\n');
elseif ischar(varargin{1,vi + 1})
vInsertHypos = str2num(varargin{1,vi + 1});
elseif isnumeric(varargin{1,vi + 1})
vInsertHypos = varargin{1,vi + 1};
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'HypoAmount')
if ~ischar(varargin{1,vi + 1}) && ~isnumeric(varargin{1,vi + 1})
error('HypoAmount is not followed by a string\n');
elseif ischar(varargin{1,vi + 1})
vHypoAmount = str2num(varargin{1,vi + 1});
elseif isnumeric(varargin{1,vi + 1})
vHypoAmount = varargin{1,vi + 1};
end
vi = vi + 1;
elseif strcmp(varargin{1,vi},'OutputType')
if ~ischar(varargin{1,vi + 1})
error('OutputType is not followed by a string\n');
elseif ischar(varargin{1,vi + 1})
vOutputType = varargin{1,vi + 1};
if strcmp(vOutputType,'simple') || strcmp(vOutputType,'Simple')
vOutputType = 'simple';
elseif strcmp(vOutputType,'verbose') || strcmp(vOutputType,'Verbose')
vOutputType = 'verbose';
elseif strcmp(vOutputType,'old') || strcmp(vOutputType,'Old')
vOutputType = 'old';
else
error('OutputType is not one of to following: simple, verbose\n');
end
end
vi = vi + 1;
else
if ischar(varargin{1,vi})
error('Argument %s not supported\n',varargin{1,vi});
elseif vi > 1
error('Argument %i (after %s) not supported', vi/2,varargin{1,vi-2});
else
error('Argument %i not supported');
end
end
end
vi = vi + 1;
end
end
vMissingInfo = 0;
if ~exist('vPGDB_FlatFileFolder','var')
fprintf('Please give the pgdb flat file folder with -pgdb fullpath');
vMissingInfo = 1;
end
if ~exist('vMD_reactions_File','var')
fprintf('Please give the metabolic domains for reactions file with -rmdf fullpath');
vMissingInfo = 1;
end
if ~exist('vMD_to_annotate','var')
fprintf('Please give a list of metabolic domains to annotate by -md ''{''metabolic domain 1'';''metabolic domain 2''}');
vMissingInfo = 1;
end
if ~exist('vProtein_sequence_FastaFile','var')
fprintf('Please give the protein fasta file with -psf fullpath');
vMissingInfo = 1;
end
if ~exist('vGeneTranscriptProtein_mapping_File','var')
fprintf('Please give gene transcript protein id conversion file with -gtpf fullpath');
vMissingInfo = 1;
end
if ~exist('vGeneLocation_File','var')
fprintf('Please give gene location (position) file with -glof fullpath');
vMissingInfo = 1;
end
if ~exist('vDNA_FastaFile','var')
fprintf('Please give the masked dna fasta file with -dnaf fullpath');
vMissingInfo = 1;
end
if ~exist('vSignatureTailorFile','var')
fprintf('Please give the signature tailoring reactions file with -sitf fullpath');
vMissingInfo = 1;
end
if ~exist('vGeneOutputFile','var')
fprintf('Please give the path to where the gene summary should be stored by -gout fullpath');
vMissingInfo = 1;
end
if ~exist('vClusterOutputFile','var')
fprintf('Please give the path to where the cluster summary should be stored by -gout fullpath');
vMissingInfo = 1;
end
if vMissingInfo == 1
error('Not all mandatory arguments were accepted, run aborted.\n');
end
%% Check files if we can open the files:
fprintf('Check files for reading and writing\n');
f_check_files_for_read_write(vPGDB_FlatFileFolder, ...
vMD_reactions_File, ...
vProtein_sequence_FastaFile, ...
vGeneTranscriptProtein_mapping_File, ...
vGeneLocation_File, vDNA_FastaFile, ...
vSignatureTailorFile, vGeneOutputFile, ...
vClusterOutputFile)
vPartFinished = 0;
if vTempsaves == 1
if vTempsavesOverwrite == 1
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
elseif ~exist([vGeneLocation_File '_tempsave.mat'],'file')
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
elseif exist([vGeneLocation_File '_tempsave.mat'],'file')
vPartFinished_old_1 = vPartFinished;
load([vGeneLocation_File '_tempsave.mat'],'vPartFinished')
if vPartFinished_old_1 > vPartFinished
vPartFinished = vPartFinished_old_1;
clear vPartFinished_old
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
end
end
end
end
if exist([vGeneLocation_File '_tempsave.mat'],'file') && vRunAfterPart ~= 0
vPartFinished_old = vPartFinished;
load([vGeneLocation_File '_tempsave.mat'],'vPartFinished')
if vPartFinished >= vRunAfterPart
load([vGeneLocation_File '_tempsave.mat']); %#ok<*LOAD>
vPartFinished = vRunAfterPart;
elseif vTempsavesOverwrite == 1
vPartFinished = vPartFinished_old;
clear vPartFinished_old
else
load([vGeneLocation_File '_tempsave.mat']);
clear vPartFinished_old
end
end
%% Read in Gene-Transcript-Protein File
if vPartFinished < 1
if vVerbose >= 1
fprintf(['Read in file describing gene-ID, transcript-ID' ...
', and protein-ID conversion\n']);
end
[vMapG, vMapT, vMapP, vMapG_MapT, vMapG_MapP] = ...
f_read_in_ConversionFile(vGeneTranscriptProtein_mapping_File, ...
vVerbose);
vPartFinished = 1;
if vTempsaves == 1
if vTempsavesOverwrite == 1
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
elseif ~exist([vGeneLocation_File '_tempsave.mat'],'file')
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
elseif exist([vGeneLocation_File '_tempsave.mat'],'file')
vPartFinished_old_1 = vPartFinished;
load([vGeneLocation_File '_tempsave.mat'],'vPartFinished')
if vPartFinished_old_1 > vPartFinished
vPartFinished = vPartFinished_old_1;
clear vPartFinished_old
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
end
end
end
end
%% Map PGDB Gene-ids to reactions
if vPartFinished < 2
if vVerbose >= 1
fprintf('Read in pgdb flat files\n');
end
[vGenes_all, ~, vReactions_all, vReactions_all_Att, vG2R] = ...
f_map_pgdb_reactions_to_genes(vPGDB_FlatFileFolder, ...
vVerbose);
vPartFinished = 2;
if vTempsaves == 1
if vTempsavesOverwrite == 1
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
elseif ~exist([vGeneLocation_File '_tempsave.mat'],'file')
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
elseif exist([vGeneLocation_File '_tempsave.mat'],'file')
vPartFinished_old_1 = vPartFinished;
load([vGeneLocation_File '_tempsave.mat'],'vPartFinished')
if vPartFinished_old_1 > vPartFinished
vPartFinished = vPartFinished_old_1;
clear vPartFinished_old
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
end
end
end
end
%% Map PGDB reactions to metabolic domains
if vPartFinished < 3
if vVerbose >= 1
fprintf('Read in and map metabolic domains\n');
end
[vRxnMetaDom, vRxnMetaDom_Att, vR_MD] = ...
f_get_metabolic_domains(vMD_reactions_File, vMD_to_annotate);
%Match PGDBs to MDs
[vRpgdb_Rmd] = f_matchPGDBs_to_MDs(vG2R, vR_MD, ...
vReactions_all, vReactions_all_Att, vRxnMetaDom, vRxnMetaDom_Att);
vPartFinished = 3;
if vTempsaves == 1
if vTempsavesOverwrite == 1
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
elseif ~exist([vGeneLocation_File '_tempsave.mat'],'file')
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
elseif exist([vGeneLocation_File '_tempsave.mat'],'file')
vPartFinished_old_1 = vPartFinished;
load([vGeneLocation_File '_tempsave.mat'],'vPartFinished')
if vPartFinished_old_1 > vPartFinished
vPartFinished = vPartFinished_old_1;
clear vPartFinished_old
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
end
end
end
end
%% Lable Reactions with signature and tailoring
if vPartFinished < 4
if vVerbose >= 1
fprintf(['Label reactions with signature and tailor' ...
'ing information\n']);
end
[vSTClasses, vSigOrTail, vR_STClasses, vR_SigOrTail] = ...
f_lable_Reactions_withSigandTail(vReactions_all, ...
vReactions_all_Att, vSignatureTailorFile);
vPartFinished = 4;
if vTempsaves == 1
if vTempsavesOverwrite == 1
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
elseif ~exist([vGeneLocation_File '_tempsave.mat'],'file')
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
elseif exist([vGeneLocation_File '_tempsave.mat'],'file')
vPartFinished_old_1 = vPartFinished;
load([vGeneLocation_File '_tempsave.mat'],'vPartFinished')
if vPartFinished_old_1 > vPartFinished
vPartFinished = vPartFinished_old_1;
clear vPartFinished_old
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
end
end
end
end
%% Map PGDB genes to Maping genes
if vPartFinished < 5
if vVerbose >= 1
fprintf('Map pgdb genes to conversion file gene-IDs\n');
end
vGenesDat_GeneInfo = upper(regexprep(vGenesDat_GeneInfo,'-','_'));
vMapG_Gpgdb = f_map_PGDBs_to_conversion_file(vMapG, vMapT, vMapP, vMapG_MapT, vMapG_MapP, vGenes_all, ...
vGenesDat_GeneInfo, vPGDBIdsToMap, vVerbose);
vPartFinished = 5;
if vTempsaves == 1
if vTempsavesOverwrite == 1
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
elseif ~exist([vGeneLocation_File '_tempsave.mat'],'file')
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
elseif exist([vGeneLocation_File '_tempsave.mat'],'file')
vPartFinished_old_1 = vPartFinished;
load([vGeneLocation_File '_tempsave.mat'],'vPartFinished')
if vPartFinished_old_1 > vPartFinished
vPartFinished = vPartFinished_old_1;
clear vPartFinished_old
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
end
end
end
end
%% Create MCL clustering mapped to Maping genes
if vPartFinished < 6
if vMCLClusterFile == 0
if vVerbose >= 1
fprintf(['Create MCL clustering based on protein file a' ...
'nd map cluster IDs to conversion gene-IDs\n']);
end
[vG_MCL, vProtein_IDs] = f_get_MCL_clustering(vProtein_sequence_FastaFile, ...
vMapG, vMapP, vMapG_MapP, vPara, vOverwriteMCLClustering, vRemoveNonProtLocations, vVerbose);
else
if vVerbose >= 1
fprintf(['Read in MCL clustering and map cluster ID' ...
's to conversion gene-IDs\n']);
end
[vG_MCL, vProtein_IDs] = ...
f_read_MCL_clustering_File(vProtein_sequence_FastaFile, ...
vMapG, vMapP, vMapG_MapP, vRemoveNonProtLocations, vVerbose);
end
vPartFinished = 6;
if vTempsaves == 1
if vTempsavesOverwrite == 1
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
elseif ~exist([vGeneLocation_File '_tempsave.mat'],'file')
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
elseif exist([vGeneLocation_File '_tempsave.mat'],'file')
vPartFinished_old_1 = vPartFinished;
load([vGeneLocation_File '_tempsave.mat'],'vPartFinished')
if vPartFinished_old_1 > vPartFinished
vPartFinished = vPartFinished_old_1;
clear vPartFinished_old
save([vGeneLocation_File '_tempsave.mat'],'-regexp','^(?!vRunAfterPart$).','-v7.3');
end
end
end
end
%% Read in Gene Position File
if vPartFinished < 7
if vVerbose >= 1
fprintf('Read in gene position file\n');
end
[vGeneLocation, vGeneLocation_Att] = ...
f_extract_results_with_header(vGeneLocation_File);
if vVerbose >= 2
fprintf('Gene Location File Attributes:\n')
for vi = 1:size(vGeneLocation_Att,2)
if ~iscell(vGeneLocation_Att(1,vi))
fprintf('Attribute %i is broken.\n', vi);
else
fprintf('Attribute %i: %s\n', vi, char(vGeneLocation_Att(1,vi)));
end
end
end
%Remove protein or transcript information
if vVerbose >= 2
fprintf('Remove transcript information\n');
end
[vGeneLocation] = ...
f_remove_protein_transcript_info_from_genepositionfile(...
vGeneLocation, vGeneLocation_Att, vMapG, vMapT, vMapP, vMapG_MapT, ...
vMapG_MapP, vVerbose);
%Consolidate gene information (one entry per gene)
if vVerbose >= 2
fprintf('Consolidate gene information\n');
end
[vUniqueChrom, vGeneLocation2] = ...
f_consolidate_gene_info(vGeneLocation, vGeneLocation_Att, vVerbose);