-
Notifications
You must be signed in to change notification settings - Fork 2
/
DataProject.java
1637 lines (1564 loc) · 82.1 KB
/
DataProject.java
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tappas;
import javafx.application.Platform;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.chart.XYChart;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.TableView;
import tappas.DataApp.DataType;
import tappas.DbProject.AFStatsData;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
/**
* @author Hector del Risco - [email protected] & Pedro Salguero - [email protected]
*/
public class DataProject extends AppObject {
//normalized
public boolean normalized = false;
public static final String FOLDER_PROJECT = "Project.";
public static String getProjectFolderName(String id) { return(FOLDER_PROJECT + id + DataApp.APP_FOLDER_EXT); }
public static String getProjectNamePrefix() { return FOLDER_PROJECT; }
public static String getProjectNameExt() { return DataApp.APP_FOLDER_EXT; }
public static String getProjectFolderFilename(String id) { return(FOLDER_PROJECT + id + DataApp.APP_FOLDER_EXT); }
// Project folders
public static final String FOLDER_ID = "InputData";
public static final String FOLDER_DATA = "Data";
// Data sub folders
public static final String FOLDER_CONTENT = "Content";
// Functional Diversity Analysis
public static final String FOLDER_FDA = "FDA";
// Differential Analysis
public static final String FOLDER_DEA = "DEA";
public static final String FOLDER_DIU = "DIU";
// Differential Feature Inclusion DIU
public static final String FOLDER_DFI = "DFI";
// Differential Alternative PolyA Analysis
public static final String FOLDER_DPA = "DPA";
// UTRLengthening
public static final String FOLDER_UTRL = "UTRL";
// Enrichment Analysis
public static final String FOLDER_GSEA = "GSEA";
public static final String FOLDER_FEA = "FEA";
public static final String CHECK_PACKAGES = "check_packages";
// InputData files
public static final String EXP_DESIGN = "experimental_design.tsv";
public static final String EXP_MATRIX = "expression_matrix.tsv";
public static final String INPUT_MATRIX = "input_matrix.tsv";
public static final String ORIGINAL_MATRIX = "original_matrix.tsv";
public static final String INPUT_MATRIX_FILTERED_TRANS = "input_matrix_filtered_trans.tsv";
public static final String INPUT_MATRIX_NATRANS = "input_matrix_NA_trans.tsv";
public static final String INPUT_MATRIX_NATROW = "input_matrix_NA_row.tsv";
public static final String INPUT_NORM_MATRIX = "input_normalized_matrix.tsv";
public static final String RESULT_MATRIX = "result_matrix.tsv";
public static final String EXP_FACTORS = "exp_factors.txt";
public static final String TIME_FACTORS = "time_factors.txt";
public static final String ID_COMPLETED = "done_inputdata.txt";
public static final String TRANS_DBCATIDS = "trans_db_cat_ids.tsv";
public static final String ANNOTATION_FEATURE_SIZES = "feature_sizes.tsv";
public static final String ANNOTATION_BLOCK_FEATURES = "block_features.tsv";
public static final String ANNOTATION_GENEDESC = "gene_descriptions.tsv";
public static final String ANNOTATION_PROTEINDESC = "protein_descriptions.tsv";
public static final String ALIGNMENT_CATEGORIES = "alignment_cats.tsv";
public static final String ANNOTATION_FILE = "annotations.gff3";
public static final String ANNOTATION_IDX = "annotations.idx";
// Project level files used for DEA/DIU and DFI
public static final String TRANS_MATRIX = "transcript_matrix.tsv";
public static final String MATRIXMEANLOG_NAME = "_matrix_meanLog";
public static final String TRANS_MATRIX_RAW = "transcript_matrix_raw.tsv";
public static final String PROT_MATRIX = "protein_matrix.tsv";
public static final String PROT_MATRIX_RAW = "protein_matrix_raw.tsv";
public static final String GENE_MATRIX = "gene_matrix.tsv";
public static final String GENE_MATRIX_RAW = "gene_matrix_raw.tsv";
public static final String GENEPROT_MATRIX = "gene_protein_matrix.tsv";
public static final String GENEPROT_MATRIX_RAW = "gene_protein_matrix_raw.tsv";
public static final String TRANS_LENGTHS = "transcript_lengths.tsv";
public static final String PROT_LENGTHS = "protein_lengths.tsv";
public static final String GENE_LENGTHS = "gene_lengths.tsv";
public static final String GENE_TRANS = "gene_transcripts.tsv";
public static final String GENE_PROTEINS = "gene_proteins.tsv";
//FDA
public static final String FDA_COMBINED_PLOT_NAME = "_FDA_CombinedResults";
//DIU
public static final String SCATTER_PLOT_NAME = "_scatter_plot";
public static final String MATRIX_DIU = "_diu_matrix";
//DPA
public static final String HEATMAP_NAME = "heatmap_plot";
//UTR Lengthening
public static final String UTRBOX_NAME = "utr_plot";
public static final String DFI_PLOT1_NAME = "dfi_bar_plot1";
public static final String DFI_PLOT2_NAME = "dfi_bar_plot2";
public static final String DFI_PLOT3_NAME = "dfi_bar_plot3";
public static final String DFI_PLOT4_NAME = "dfi_bar_plot4";
public static final String MATRIX_DFI = "dfi_matrix";
public static final String DFI_TOTAL_FEATURES = "dfi_total_features";
public static final String DFI_TEST_FEATURES = "dfi_test_features";
public static final String DFI_TEST_GENES = "dfi_test_genes";
// Project level files used for DAPA
public static final String STRUCTURAL_INFO = "structural_info.tsv";
public static final List<String> STRUCTURAL_FEATURES = Arrays.asList("3'UTR Length", "5'UTR Length", "CDS Length", "PolyAdenylation Site");
public static final String DPA_ShortLong = "dpa_info.tsv";
public static final String UTRL_ShortLong = "utrl_info.tsv";
public static final String UTRL_PVAL = "result_pval.tsv";
// RankedLists for GSEA - want to keep file names different from FEA
public static final String RANKEDLIST_LENGTHS = "RLlengths";
public static final String RANKEDLIST_VALUES = "RLvalues";
// Test and Background lists for FEA
public static final String LIST_LENGTHS = "lengths";
public static final String LIST_TEST = "test";
public static final String LIST_BKGND = "bkgnd";
// PCA
public static final String MATRIX_PCA_DATA = "matrix_pca.tsv";
//Chormosome Data
static private final List<String> CHR_SPECIES = Arrays.asList("Mus_musculus", "Homo_sapiens");
public List<String> getChromoDataSpecies() {return CHR_SPECIES;}
//analysis path
public String getDFIFolder(){return Paths.get(getProjectFolder(), FOLDER_DFI).toString(); }
// file paths and names
public String getProjectFolderName() { return(getProjectFolderName(project.getProjectId())); }
public String getProjectFolder() { return Paths.get(app.data.getAppProjectsFolder(), getProjectFolderName()).toString(); }
public String getProjectToolLogFilepath(String tool) { return Paths.get(getProjectFolder(), tool + "_" + DataApp.LOG_NAME).toString(); }
public String getProjectToolJpgFilepath(String tool) { return Paths.get(getProjectFolder(), tool + DataApp.JPG_EXT).toString(); }
public String getInputDataFolder() { return Paths.get(getProjectFolder(), FOLDER_ID).toString(); }
public String getProjectDataFolder() { return Paths.get(getProjectFolder(), FOLDER_DATA).toString(); }
public String getResultsFilepath() { return Paths.get(getProjectDataFolder(), DataApp.RESULTS_GENE_TRANS).toString(); }
public String getResultsGeneProtFilepath() { return Paths.get(getProjectDataFolder(), DataApp.RESULTS_GENE_PROT).toString(); }
public String getContentFolder() { return Paths.get(getProjectDataFolder(), FOLDER_CONTENT).toString(); }
public String getSubTabLogFilepath(String subTab) { return Paths.get(getContentFolder(), subTab.toLowerCase() + "_" + DataApp.LOG_NAME).toString(); }
public String getMatrixMeanLogExpLevelsFilepath(String dataType) { return Paths.get(getContentFolder(), dataType.toLowerCase() + MATRIXMEANLOG_NAME + DataApp.TSV_EXT).toString(); }
public String getMatrixMeanLogExpLevelsPlotFilepath(String dataType) { return Paths.get(getContentFolder(), dataType.toLowerCase() + MATRIXMEANLOG_NAME + DataApp.PNG_EXT).toString(); }
public String getMatrixPCAFilepath() { return Paths.get(getContentFolder(), MATRIX_PCA_DATA).toString(); }
// Check Packages
public String getCheckPackagesFilepath() { return Paths.get(getContentFolder(), CHECK_PACKAGES + DataApp.TEXT_EXT).toString(); }
//FDA
public String getFDACombinedResultsPlotFilepath() { return Paths.get(getContentFolder(), "tappAS" + FDA_COMBINED_PLOT_NAME + DataApp.PNG_EXT).toString(); }
// DIU graph
public String getScatterPlotFilepath(String dataType) { return Paths.get(getContentFolder(), dataType.toLowerCase() + SCATTER_PLOT_NAME + DataApp.PNG_EXT).toString(); }
public String getMatrixDIUFilepath(String dataType) { return Paths.get(getContentFolder(), dataType.toLowerCase() + MATRIX_DIU + DataApp.TSV_EXT).toString(); }
// DFI graph
public String getDFILogFilepath(String id) { return Paths.get(getDFIFolder(), DataApp.LOG_PREFIXID + id + DataApp.LOG_EXT).toString(); }
public String getDFIPlot1Filepath(String id) { return Paths.get(getContentFolder(), DFI_PLOT1_NAME + "." + id + DataApp.PNG_EXT).toString(); }
public String getDFIPlot2Filepath(String id) { return Paths.get(getContentFolder(), DFI_PLOT2_NAME + "." + id + DataApp.PNG_EXT).toString(); }
public String getDFIPlot3Filepath(String id) { return Paths.get(getContentFolder(), DFI_PLOT3_NAME + "." + id + DataApp.PNG_EXT).toString(); }
public String getDFIPlot4Filepath(String id) { return Paths.get(getContentFolder(), DFI_PLOT4_NAME + "." + id + DataApp.PNG_EXT).toString(); }
public String getMatrixDFIFilepath(String id) { return Paths.get(getContentFolder(), MATRIX_DFI + "." + id + DataApp.TSV_EXT).toString(); }
public String getDFITotalFeaturesFilepath(String id) { return Paths.get(getContentFolder(), DFI_TOTAL_FEATURES + "." + id + DataApp.TSV_EXT).toString(); }
public String getDFITestFeaturesFilepath(String id) { return Paths.get(getContentFolder(), DFI_TEST_FEATURES + "." + id + DataApp.TSV_EXT).toString(); }
public String getDFITestGenesFilepath(String id) { return Paths.get(getContentFolder(), DFI_TEST_GENES + "." + id + DataApp.TSV_EXT).toString(); }
// DPA graph
public String getDPAHeatmapFilepath() { return Paths.get(getContentFolder(), HEATMAP_NAME + DataApp.PNG_EXT).toString(); }
// UTR graph
public String getUTRPlotFilepath() { return Paths.get(getContentFolder(), UTRBOX_NAME + DataApp.PNG_EXT).toString(); }
public HashMap<String, String> getUTRPVal() { return Utils.loadSingleStringTSVListFromFile(Paths.get(project.data.getProjectDataFolder(),"UTRL",UTRL_PVAL).toString(), true); }
public String getProjectParamFilepath() { return Paths.get(getProjectFolder(), DataApp.PRM_PROJECT).toString(); }
public String getProjectIDParamFilepath() { return Paths.get(getInputDataFolder(), DataApp.PRM_PROJECT_DATA).toString(); }
// project annotation file names
public String getAnnotationFilepath() { return annotationFilepath; }
public String getAnnotationDBFilepath() { return getAnnotationFilepath().isEmpty()? "" : Paths.get(getAnnotationFilepath(), DataApp.ANNOTATION_DB).toString(); }
public String getProjectDBFilepath() { return Paths.get(getProjectFolder(), DataApp.PROJECT_DB).toString(); }
// file names
public String getAnnotationBlockFeaturesFilepath() { return Paths.get(getProjectDataFolder(), ANNOTATION_BLOCK_FEATURES).toString(); }
public String getResultMatrixFilepath() { return( Paths.get(getProjectDataFolder(), RESULT_MATRIX).toString()); }
public String getOriginalMatrixFilepath() { return Paths.get(getInputDataFolder(), ORIGINAL_MATRIX).toString(); }
public String getDesignFilepath() { return Paths.get(getInputDataFolder(), EXP_DESIGN).toString(); }
public String getInputMatrixFilepath() { return Paths.get(getInputDataFolder(), INPUT_MATRIX).toString(); }
public String getInputNormMatrixFilepath() { return Paths.get(getInputDataFolder(), INPUT_NORM_MATRIX).toString(); }
public String getInputFactorsFilepath() { return Paths.get(getInputDataFolder(), EXP_FACTORS).toString(); }
public String getInputTimeFactorsFilepath() { return Paths.get(getInputDataFolder(), TIME_FACTORS).toString(); }
public String getInputTransLenFilepath() { return Paths.get(getAnnotationFilepath(), TRANS_LENGTHS).toString(); }
public String getInputMatrixNATransFilepath() { return Paths.get(getInputDataFolder(), INPUT_MATRIX_NATRANS).toString(); }
public String getInputMatrixFilteredTransFilepath() { return Paths.get(getInputDataFolder(), INPUT_MATRIX_FILTERED_TRANS).toString(); }
// not really open to external change - single global file for now - see note in AnnotationFileDefs
public String getAnnotationDefFilepath() { return app.data.getAppAnnotationDefFilepath(); }
// files for data analysis input
public String getExpFactorsFilepath() { return Paths.get(project.data.getProjectDataFolder(), EXP_FACTORS).toString(); }
public String getTimeFactorsFilepath() { return Paths.get(project.data.getProjectDataFolder(), TIME_FACTORS).toString(); }
public String getGeneTransFilePath() { return Paths.get(project.data.getProjectDataFolder(), GENE_TRANS).toString(); }
public String getGeneProteinsFilePath() { return Paths.get(project.data.getProjectDataFolder(), GENE_PROTEINS).toString(); }
public String getStructuralInfoFilePath() { return Paths.get(project.data.getProjectDataFolder(), STRUCTURAL_INFO).toString(); }
public String getGeneMatrixFilepath() { return Paths.get(project.data.getProjectDataFolder(), GENE_MATRIX).toString(); }
public String getGeneMatrixRawFilepath() { return Paths.get(project.data.getProjectDataFolder(), GENE_MATRIX_RAW).toString(); }
public String getTranscriptMatrixFilepath() { return Paths.get(project.data.getProjectDataFolder(), TRANS_MATRIX).toString(); }
public String getTranscriptMatrixRawFilepath() { return Paths.get(project.data.getProjectDataFolder(), TRANS_MATRIX_RAW).toString(); }
public String getProteinMatrixFilepath() { return Paths.get(project.data.getProjectDataFolder(), PROT_MATRIX).toString(); }
public String getProteinMatrixRawFilepath() { return Paths.get(project.data.getProjectDataFolder(), PROT_MATRIX_RAW).toString(); }
public String getGeneProteinMatrixFilepath() { return Paths.get(project.data.getProjectDataFolder(), GENEPROT_MATRIX).toString(); }
public String getGeneProteinMatrixRawFilepath() { return Paths.get(project.data.getProjectDataFolder(), GENEPROT_MATRIX_RAW).toString(); }
// application objects
AnnotationFileDefs fileDefs;
String annotationFilepath = "";
private DataAnnotation dataAnnotation;
private DbAnnotation dbAnnotation;
private DbProject dbProject;
DataInputMatrix dataInputMatrix;
private DataExpMatrix dataExpMatrix;
public Analysis analysis;
private boolean dataLoading = false;
private boolean dataLoaded = false;
public boolean isDataLoaded() { return dataLoaded; }
public boolean isDataLoading() { return dataLoading; }
public DataAnnotation getDataAnnotation() { return dataAnnotation; }
public Analysis getAnalysis() { return analysis; }
public AnnotationFileDefs getAnnotationFileDefs() { return fileDefs; }
// class data
public static String rscriptPath = "Rscript";
DlgInputData.Params params = new DlgInputData.Params(new HashMap<>());
HashMap<String, HashMap<String, Object>> hmResultsGeneTrans = new HashMap<>();
HashMap<String, Object> hmResultsTrans = new HashMap<>();
public DataProject(Project project) {
super(project, null);
// TODO: remove from here later?... but try to figure out why it was placed in the constructor to begin with!!!
this.analysis = new Analysis(project);
}
public void initialize() throws Exception {
logger.logDebug("Initializing data for project '" + project.getProjectName() + "' (" + project.getProjectId() + ")...");
// create folders if needed
Utils.createFolder(getInputDataFolder());
Utils.createFolder(getProjectDataFolder());
Utils.createFolder(getContentFolder());
// load input data parameters
params = DlgInputData.Params.load(getProjectIDParamFilepath());
normalized = params.norm;
//if annotation file change in the folder the project can be loaded because tappAS has a list with all references and its sizes!!!
annotationFilepath = app.data.getAnnotationFeaturesFolder(params);
if(annotationFilepath.isEmpty()){
app.logInfo("The custom annotation file has been modified. We are going to load the version you used to create the project.");
annotationFilepath = app.data.getAnnotationFeaturesFolderWithoutSize(params);
if(annotationFilepath == null){
app.logInfo("We can not find your annotation. The projact can not be loaded.");
return;
}else{
app.logInfo("Annotation loaded correctly. Check if the project contains the correct annotation or you want to create a new one.");
}
}
hmResultsGeneTrans = readResults();
hmResultsTrans.clear();
for(HashMap<String, Object> hm : hmResultsGeneTrans.values()) {
for(String trans : hm.keySet())
hmResultsTrans.put(trans, null);
}
// initialize annotation objects
loadAnnotationsFileDefs();
dataAnnotation = new DataAnnotation(project);
dataAnnotation.initialize();
dbAnnotation = new DbAnnotation(project);
dbAnnotation.initialize();
dbProject = new DbProject(project);
dbProject.initialize();
// initialize input data expression matrix object
dataInputMatrix = new DataInputMatrix(project);
dataInputMatrix.initialize();
// initialize project expression matrix object
dataExpMatrix = new DataExpMatrix(project);
dataExpMatrix.initialize();
// initialize analysis object
analysis.initialize();
// load initial data if available - change this later to not happen here!!!
// ideally to not happen at all until some data is needed
initializeData();
logger.logDebug("Project data initialization completed.");
}
// must have already created/downloaded annotation DB
private boolean initializeData() {
boolean result = false;
// check if we already have the annotation data path
// it is possible to run without having the data yet
// if the code tried to access the data then it would fail
if(!getAnnotationFilepath().isEmpty()) {
logger.logDebug("AnnotFile: " + getAnnotationFilepath());
logger.logDebug("AnnotDB: " + getAnnotationDBFilepath());
// check if annotation DB already created, otherwise don't try to open it
System.out.println("path: " + Paths.get(getAnnotationDBFilepath()).toString());
if(Files.exists(Paths.get(getAnnotationDBFilepath()))) {
if(dbAnnotation.openDB(getAnnotationDBFilepath())) {
logger.logDebug("ProjectDB: " + getProjectDBFilepath());
// check if project DB already created, otherwise don't try to open it
// return true since the project creation is taking place
if(Files.exists(Paths.get(getProjectDBFilepath()))) {
result = dbProject.openDB(getProjectDBFilepath());
if(result) {
// create structural file if it has not created yet
//if(!Files.exists(Paths.get(getStructuralInfoFilePath()))){
// dbAnnotation.getStructureFile(project.data.getProjectDataFolder(), dbAnnotation.getTranscriptGenomicPosition());
//}
// start data load on background task, will set flags accordingly
runLoadData();
}
}
else
result = true;
}
}
}
return result;
}
//
// Project Data Functions
//
public boolean hasResults() {
boolean has = false;
String filepath = getResultsFilepath();
if(Files.exists(Paths.get(filepath)))
has = true;
return has;
}
public HashMap<String, HashMap<String, Object>> getResultsGeneTrans() { return hmResultsGeneTrans; }
public HashMap<String, Object> getResultsGenes() {
HashMap<String, Object> hmGenes = new HashMap<>();
for(String gene : hmResultsGeneTrans.keySet())
hmGenes.put(gene, null);
return hmGenes;
}
public HashMap<String, Object> getResultsTrans() { return hmResultsTrans; }
public HashMap<String, Object> getResultsProteins() {
HashMap<String, Object> hmResultsProteins = new HashMap<>();
for(String trans : hmResultsTrans.keySet()) {
String protein = getTransProtein(trans).trim();
if(!protein.isEmpty())
hmResultsProteins.put(protein, null);
}
return hmResultsProteins;
}
public HashMap<String, HashMap<String, Object>> readResults() {
hmResultsGeneTrans.clear();
hmResultsTrans.clear();
String filepath = getResultsFilepath();
try {
if(Files.exists(Paths.get(filepath))) {
List<String> lines = Files.readAllLines(Paths.get(filepath), StandardCharsets.UTF_8);
for(String line : lines) {
String[] fields = line.split("\t");
if(fields.length == 2) {
if(!hmResultsGeneTrans.containsKey(fields[0].trim())) {
HashMap<String, Object> hm = new HashMap<>();
hm.put(fields[1].trim(), null);
hmResultsGeneTrans.put(fields[0].trim(), hm);
}
else
hmResultsGeneTrans.get(fields[0].trim()).put(fields[1].trim(), null);
}
else if(fields.length != 1){
logger.logError("Invalid line, " + line + ", in file '" + filepath + "'");
hmResultsGeneTrans.clear();
break;
}
}
}
}
catch (Exception e) {
logger.logError("Unable to load project results file '" + filepath + "': " + e.getMessage());
hmResultsGeneTrans.clear();
}
for(HashMap<String, Object> hm : hmResultsGeneTrans.values()) {
for(String trans : hm.keySet())
hmResultsTrans.put(trans, null);
}
return hmResultsGeneTrans;
}
public boolean writeResults(HashMap<String, HashMap<String, Object>> hmGeneTrans) {
boolean result = false;
hmResultsGeneTrans.clear();
hmResultsTrans.clear();
Writer writer = null;
String filepath = getResultsFilepath();
try {
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filepath), "utf-8"));
for(String gene : hmGeneTrans.keySet()) {
HashMap<String, Object> hmTrans = hmGeneTrans.get(gene);
for(String trans : hmTrans.keySet())
writer.write(gene + "\t" + trans + "\n");
}
hmResultsGeneTrans = hmGeneTrans;
for(HashMap<String, Object> hm : hmResultsGeneTrans.values()) {
for(String trans : hm.keySet())
hmResultsTrans.put(trans, null);
}
result = true;
} catch (IOException e) {
logger.logError("Unable to save project file '" + filepath +"': " + e.getMessage());
} finally {
try {if(writer != null) writer.close();} catch (Exception e) { System.out.println("Writer close exception within exception: " + e.getMessage()); }
}
return result;
}
public void removeResultFile() {
Path filePath = Paths.get(getResultsFilepath());
if(Files.exists(filePath))
Utils.removeFile(filePath);
}
public void removeResultMatrixFile() {
Path filePath = Paths.get(getResultMatrixFilepath());
if(Files.exists(filePath))
Utils.removeFile(filePath);
}
//
// Project Settings Functions
//
public String getGenus() {
return params.genus;
}
public String getSpecies() {
return params.species;
}
public DataApp.RefType getRefType() {
return params.refType;
}
public DataApp.ExperimentType getExperimentType() {
return params.experimentType;
}
public boolean isMultipleTimeSeriesExpType() {
return params.experimentType.equals(DataApp.ExperimentType.Time_Course_Multiple);
}
public boolean isSingleTimeSeriesExpType() {
return params.experimentType.equals(DataApp.ExperimentType.Time_Course_Single);
}
public boolean isTimeCourseExpType() {
return (isSingleTimeSeriesExpType() || isMultipleTimeSeriesExpType());
}
public boolean isCaseControlExpType() {
return params.experimentType.equals(DataApp.ExperimentType.Two_Group_Comparison);
}
//
// Data Load
//
private void runLoadData() {
// run background code to load initial project data
Thread thread = new LoadDataThread();
thread.start();
}
private class LoadDataThread extends Thread {
@Override
public void run(){
dataLoading = true;
logger.logDebug("Load project data thread running");
try {
if(dbAnnotation.openDB(getAnnotationDBFilepath())) {
// check if project DB already created, otherwise don't try to open it
if(Files.exists(Paths.get(getProjectDBFilepath()))) {
boolean result = dbProject.openDB(getProjectDBFilepath());
if(result) {
// start data load on background task
result = dataAnnotation.loadBaseData();
dataLoading = false;
dataLoaded = result;
if(dataLoaded) {
Platform.runLater(() -> {
app.ctlr.projectDataLoaded(project);
});
}
}
}
//if(!Files.exists(Paths.get(getProjectDBFilepath()))) {
// dbAnnotation.getStructureFile(project.getProjectFolder()+"/Data/", dbAnnotation.getTranscriptGenomicPosition());
//}
}
} catch(Exception e) {
app.logger.logError("Unable to load project data: " + e.getMessage());
}
logger.logDebug("Load project data thread exiting.");
}
}
// get all annotation transcripts from dbAnnotation
// only use for generating the master expression matrix
// since at that point the project DB has not been created
public HashMap<String, Object> getAnnotationTrans(){
return dbAnnotation.loadTrans();
}
public boolean createProjectDB(double offset, double featuresPart, ProgressBar pbProgress){
boolean result = false;
// create project DB
dbProject = new DbProject(project);
dbProject.initialize();
// get the list of transcripts after all the filtering (expression and transcripts data) is done
ArrayList<String> lstTrans = Utils.loadSingleItemListFromFile(getResultMatrixFilepath(), true);
if(!lstTrans.isEmpty()) {
if(dbProject.createDB(getProjectDBFilepath(), Paths.get(getAnnotationFilepath(), DataApp.ANNOTATION_DB).toString(), lstTrans, offset, featuresPart, pbProgress))
result = true;
}
return result;
}
// wipes out all the project data - in the data folder
// called when reloading input data - all data will be affected
public void removeProjectData() {
app.data.removeFolder(Paths.get(getProjectDataFolder()));
Utils.createFolder(getProjectDataFolder());
analysis.createFolders();
}
public void removeProjectDB() {
Utils.removeFile(Paths.get(getProjectDBFilepath()));
}
public boolean hasResultMatrixFile() {
return Files.exists(Paths.get(getResultMatrixFilepath()));
}
public void clearData() {
}
public void clearDataFolder(boolean rmvprm) {
Utils.removeAllFolderFiles(Paths.get(getProjectDataFolder()), rmvprm);
}
public void clearInputDataFolder(boolean rmvprm) {
Utils.removeAllFolderFiles(Paths.get(getInputDataFolder()), rmvprm);
}
// get annotation file definitions
private void loadAnnotationsFileDefs() throws Exception {
// load annotation file definition if not already done
if(fileDefs == null) {
// load file, will throw exception
fileDefs = new AnnotationFileDefs(project, null);
// see note in AnnotationFileDefs
fileDefs.loadDefinitions(getAnnotationDefFilepath());
}
}
//
// Project Parameters Data Functions
//
//public HashMap<String, String> getIDParams() { return IDParams; }
public DlgInputData.Params getParams() { return params; }
public void setParams(DlgInputData.Params params) {
this.params = params;
params.save(getProjectIDParamFilepath());
}
/*
public void setIDParams(HashMap<String, String> hmp) {
IDParams = hmp;
if(IDParams != null)
Utils.saveParams(IDParams, getProjectIDParamFilepath());
}*/
public static String getProjectIdHash(String name) {
String hashCode = name.hashCode() + "";
if(hashCode.charAt(0) == '-')
hashCode = hashCode.substring(1);
return(FOLDER_PROJECT + hashCode + DataApp.APP_FOLDER_EXT);
}
//
// Project Data
//
//
// Expression Matrix
//
//
// result expression matrix interface
//
public double[][] getMeanExpressionLevels(DataType type, HashMap<String, Object> hmFilterTrans) {
return dataExpMatrix.getMeanExpressionLevels(type, hmFilterTrans);
}
public HashMap<String, double[]> getMeanExpressionLevelsHM(DataType type, HashMap<String, Object> hmFilterTrans) {
return dataExpMatrix.getMeanExpressionLevelsHM(type, hmFilterTrans);
}
public HashMap<String, double[][]> getMeanExpressionLevelsSD_HM(DataType type, HashMap<String, Object> hmFilterTrans) {
return dataExpMatrix.getMeanExpressionLevelsSD_HM(type, hmFilterTrans);
}
public DataExpMatrix.ExpressionLevelsDistribution getMeanLog10ExpressionLevelsDistribution(DataType type, HashMap<String, Object> hmFilterTrans) {
return dataExpMatrix.getMeanLog10ExpressionLevelsDistribution(type, hmFilterTrans);
}
public DataInputMatrix.ExpMatrixData getExpressionData(DataType type, HashMap<String, Object> hmFilterTrans) {
return(dataExpMatrix.getExpressionData(false, type, hmFilterTrans));
}
public HashMap<String, HashMap<String, Object>> getExpressedGeneTransFilter(HashMap<String, Object> hmFilterTrans) {
return dataExpMatrix.getExpressed(hmFilterTrans);
}
public ArrayList<Integer> getExpressedTransLengthArray(HashMap<String, Object> hmFilterTrans) {
HashMap<String, HashMap<String, Object>> hmGeneTrans = dataExpMatrix.getExpressed(hmFilterTrans);
return getTransLengthArray(hmGeneTrans);
}
public ArrayList<Integer> getExpressedProteinsLengthArray(HashMap<String, Object> hmFilterTrans) {
HashMap<String, HashMap<String, Object>> hmGeneTrans = dataExpMatrix.getExpressed(hmFilterTrans);
return getProteinsLengthArray(hmGeneTrans);
}
public HashMap<String, Object> getExpressedTrans(HashMap<String, Object> hmFilterTrans) {
return dataExpMatrix.getExpressedTrans(hmFilterTrans);
}
public HashMap<String, HashMap<String, Integer>> getExpressedGeneIsoformsLength(HashMap<String, Object> hmFilterTrans) {
return dataExpMatrix.getExpressedGeneIsoformsLength(hmFilterTrans);
}
public HashMap<String, Integer> getExpressedGeneIsoformsCount(HashMap<String, Object> hmFilterTrans) {
return dataExpMatrix.getExpressedGeneIsoformsCount(hmFilterTrans);
}
public HashMap<String, Integer> getExpressedGeneAssignedProteinsCount(HashMap<String, Object> hmFilterTrans) {
return dataExpMatrix.getExpressedGeneAssignedProteinsCount(hmFilterTrans);
}
public int getExpressedAssignedProteinsCount(HashMap<String, Object> hmFilterTrans) {
return dataExpMatrix.getExpressedAssignedProteinsCount(hmFilterTrans);
}
public HashMap<String, Boolean> getExpressedIsoformsCoding(HashMap<String, Object> hmFilterTrans) {
return dataExpMatrix.getExpressedIsoformsCoding(hmFilterTrans);
}
public DataProject.DistributionData getExpressedTransDistribution(HashMap<String, Object> hmFilterTrans) {
return dataExpMatrix.getExpressedTransDistribution(hmFilterTrans);
}
public DataProject.DistributionData getExpressedProtDistribution(HashMap<String, Object> hmFilterTrans) {
return dataExpMatrix.getExpressedProtDistribution(hmFilterTrans);
}
public boolean genResultMatrixFile(HashMap<String, Object> hmFilterTrans) {
return dataExpMatrix.genResultMatrixFile(hmFilterTrans);
}
// geneProtein is used to create a gene_protein id which is required for DIU
public boolean genExpressionFile(DataType dataType, boolean geneProtein) {
boolean result = false;
switch(dataType) {
case GENE:
// this file includes all the genes in the project, there is no need to recreate it each time
if(!Files.exists(Paths.get(project.data.getGeneMatrixFilepath())))
result = dataExpMatrix.genExpressionFile(dataType, false, getResultsTrans(), getGeneMatrixFilepath());
else
result = true;
break;
case TRANS:
// this file includes all the transcripts in the project, there is no need to recreate it each time
if(!Files.exists(Paths.get(project.data.getTranscriptMatrixFilepath())))
result = dataExpMatrix.genExpressionFile(dataType, false, getResultsTrans(), getTranscriptMatrixFilepath());
else
result = true;
break;
case PROTEIN:
// set for either protein or gene_protein ids file
String filepath = geneProtein? project.data.getGeneProteinMatrixFilepath() : project.data.getProteinMatrixFilepath();
// this file includes all the proteins or gene-proteins in the project, there is no need to recreate it each time
if(!Files.exists(Paths.get(filepath)))
result = dataExpMatrix.genExpressionFile(dataType, geneProtein, getResultsTrans(), filepath);
else
result = true;
break;
}
return result;
}
public ObservableList<Analysis.DataSelectionResults> getDataSelectionResults(DataType dataType) {
ObservableList<Analysis.DataSelectionResults> data = FXCollections.observableArrayList();
DataInputMatrix.ExpMatrixData emdata;
HashMap<String, double[]> hmMEL = getMeanExpressionLevelsHM(dataType, hmResultsTrans);
emdata = getExpressionData(dataType, hmResultsTrans);
if(emdata != null) {
for(DataInputMatrix.ExpMatrixArray rowdata : emdata.data) {
Analysis.DataSelectionResults dsr = new Analysis.DataSelectionResults(project, false, dataType, rowdata);
dsr.pos = getLocusPosition(dataType, dsr.getId());
if(!hmMEL.isEmpty()) {
if(hmMEL.containsKey(dsr.getId())) {
double[] conds = hmMEL.get(dsr.getId());
dsr.conditions = new SimpleDoubleProperty[conds.length];
for(int i = 0; i < conds.length; i++)
dsr.conditions[i] = new SimpleDoubleProperty(Double.parseDouble(String.format("%.02f", ((double)Math.round(conds[i]*100)/100.0))));
}
else
logger.logWarning("Unable to find expression values for '" + dsr.id + "'");
}
data.add(dsr);
}
}
return data;
}
public ObservableList<Analysis.DataSelectionResults> getOriginalExpMatrixSelectionResults() {
ObservableList<Analysis.DataSelectionResults> data = FXCollections.observableArrayList();
DataInputMatrix.ExpMatrixData emdata;
emdata = getOriginalExpressionData();
if(emdata != null) {
for(DataInputMatrix.ExpMatrixArray rowdata : emdata.data) {
Analysis.DataSelectionResults dsr = new Analysis.DataSelectionResults(project, false, DataType.TRANS, rowdata);
data.add(dsr);
}
}
return data;
}
// get gene isoforms expression levels
public HashMap<String, TransExpLevels> getGeneIsosExpLevels(String gene, HashMap<String, Object> hmFilterTrans) {
HashMap<String, double[]> hmExpLevels = dataExpMatrix.getMeanExpressionLevelsHM(DataType.TRANS, hmFilterTrans);
HashMap<String, TransExpLevels> hmResults = new HashMap<>();
HashMap<String, Object> hm = dataExpMatrix.getExpressedGeneTrans(gene, hmFilterTrans);
for(String trans : hm.keySet()) {
if(hmExpLevels.containsKey(trans)) {
double[] vals = hmExpLevels.get(trans);
hmResults.put(trans, new TransExpLevels(vals[0], vals[1]));
}
}
return hmResults;
}
public HashMap<String, double[]> getGeneTimesIsosExpLevels(String gene, HashMap<String, Object> hmFilterTrans) {
HashMap<String, double[]> hmExpLevels = dataExpMatrix.getMeanExpressionLevelsHM(DataType.TRANS, hmFilterTrans);
HashMap<String, double[]> hmResults = new HashMap<>();
HashMap<String, Object> hm = dataExpMatrix.getExpressedGeneTrans(gene, hmFilterTrans);
for(String trans : hm.keySet()) {
if(hmExpLevels.containsKey(trans)) {
double[] vals = hmExpLevels.get(trans);
hmResults.put(trans, vals);
}
}
return hmResults;
}
// get gene proteins expression levels
public HashMap<String, TransExpLevels> getGeneProtsExpLevels(String gene, HashMap<String, Object> hmFilterTrans) {
HashMap<String, double[]> hmExpLevels = dataExpMatrix.getMeanExpressionLevelsHM(DataType.PROTEIN, hmFilterTrans);
HashMap<String, TransExpLevels> hmResults = new HashMap<>();
HashMap<String, Object> hm = dataExpMatrix.getExpressedGeneProteins(gene, hmFilterTrans);
for(String protein : hm.keySet()) {
if(hmExpLevels.containsKey(protein)) {
double[] vals = hmExpLevels.get(protein);
hmResults.put(protein, new TransExpLevels(vals[0], vals[1]));
}
}
return hmResults;
}
//
// Input source matrix functions - work on the project input source matrix
//
public HashMap<String, HashMap<String, Object>> getInputMatrixFilterGeneTrans() {
return dataExpMatrix.getInputMatrixFilterGeneTrans();
}
public HashMap<String, Object> getInputMatrixFilterTrans() {
return dataExpMatrix.getInputMatrixFilterTrans();
}
public HashMap<String, double[]> getInputMatrixMeanExpressionLevelsHM(DataType type, HashMap<String, Object> hmFilterTrans) {
return dataExpMatrix.getInputMatrixMeanExpressionLevelsHM(type, hmFilterTrans);
}
//
// Source/Features data
//
public HashMap<String, HashMap<String, Object>> getAnnotFeatures() {
return dataAnnotation.getAnnotFeatures();
}
public HashMap<String, Object> getSourceFeatures(String source) {
return dataAnnotation.getSourceFeatures(source);
}
public HashMap<String, Object> getSourceFeaturesPosition(String source) {
return dataAnnotation.getSourceFeaturesPosition(source);
}
public HashMap<String, Object> getSourceFeaturesPresence(String source) {
return dataAnnotation.getSourceFeaturesPresence(source);
}
public HashMap<String, HashMap<String, AFStatsData>> getAFStats() {
return dataAnnotation.getAFStats();
}
public HashMap<String, ArrayList<String>> getAFStatsPositional() {
return dataAnnotation.getAFStatsPositional();
}
public HashMap<String, ArrayList<String>> getAFStatsPresence() {
return dataAnnotation.getAFStatsPresence();
}
public HashMap<String, HashMap<String, String>> getAFStatsType() {
return dataAnnotation.getAFStatsType();
}
public HashMap<String, AFStatsData> getSourceFeaturesStats(String source) {
return dataAnnotation.getSourceFeaturesStats(source);
}
public HashMap<String, AFStatsData> getSummaryAFStatsData(String sourceFilter, boolean includeReserved) {
return dataAnnotation.getSummaryAFStatsData(sourceFilter, includeReserved);
}
public HashMap<String, HashMap<String, Object>> loadAllAFs(){
return dbAnnotation.loadAnnotFeatures();
}
// should only be called from DataAnnotation
public HashMap<String, DataAnnotation.AnnotSourceStats> loadAnnotSourceStats(){
return dbProject.loadAnnotSourceStats();
}
public HashMap<String, HashMap<String, HashMap<String, String>>> loadFeatureDescriptions(){
return dbProject.loadFeatureDescriptions();
}
public HashMap<String, HashMap<String, AFStatsData>> loadAFStats(){
return dbProject.loadAFStats();
}
public HashMap<String, ArrayList<String>> loadAFStatsPositional(){
//return dbAnnotation.loadAFStatsPositional();
return dbProject.loadAFStatsPositional();
}
public HashMap<String, ArrayList<String>> loadAFStatsPresence(){
//return dbAnnotation.loadAFStatsPresence();
return dbProject.loadAFStatsPresence();
}
public HashMap<String, HashMap<String, String>> loadAFStatsType(){
return dbAnnotation.loadAFStatsType();
}
public HashMap<String, String> loadTransAnnotFeaturesString(){
return dbProject.loadTransAnnotFeaturesString();
}
public HashMap<String, HashMap<String, HashMap<String, Integer>>> loadTransAnnotFeatures(){
return dbProject.loadTransAnnotFeatures();
}
public HashMap<String, HashMap<String, HashMap<String, HashMap<String, String>>>> loadTransAFIdPos(){
return dbProject.loadTransAFIdPos();
}
public HashMap<String, HashMap<String, HashMap<String, HashMap<String, String>>>> loadTransAFIdGenPos(){
return dbProject.loadTransAFIdGenPos();
}
public int getIfTransHasAnnot(String trans, String source){
return dbProject.getIfTransHasAnnot(trans, source);
}
public HashMap<String, Object> getTransWithAnnot(String source){
return dbProject.getTransWithAnnot(source);
}
public int getTotalAnnot(){
return dbProject.getTotalAnnot();
}
public int getAnnotCount(String annot){
return dbProject.getAnnotCount(annot);
}
public int getAnnotCountByGene(String annot){
return dbProject.getAnnotCountByGene(annot);
}
public HashMap<String, HashMap<String, HashMap<String, HashMap<String, String>>>> loadTransAFIdPos(ArrayList<String> lstTrans){
return dbProject.loadTransAFIdPos(lstTrans);
}
public HashMap<String, HashMap<String, Object>> loadGeneTrans(){
return dbProject.loadGeneTrans();
}
public DbProject.TransDataResults loadTransData(){
return dbProject.loadTransData();
}
public ArrayList<String> loadGeneAnnotations(String gene){
return dbProject.loadGeneAnnotations(gene);
}
/*
public HashMap<String, String> loadGeneDescriptions() {
return dbProject.loadDescriptions(dataAnnotation.fileDefs.gene.source, dataAnnotation.fileDefs.gene.feature);
}
public HashMap<String, String> loadProteinDescriptions() {
return dbProject.loadDescriptions(dataAnnotation.fileDefs.protein.source, dataAnnotation.fileDefs.protein.feature);
}*/
// Results Checking Functions
public boolean hasInputData() {
return Files.exists(Paths.get(getInputDataFolder(), ID_COMPLETED));
}
public boolean writeInputDataCompletedFile() {
boolean result = false;
String filepath = Paths.get(getInputDataFolder(), ID_COMPLETED).toString();
Writer writer = null;
try {
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filepath, false), "utf-8"));
writer.write("done");
} catch(Exception e) {
logger.logError("Unable to create input data completed file: " + e.getMessage());
} finally {
try {if(writer != null) writer.close();} catch (Exception e) { System.out.println("Writer close exception within exception: " + e.getMessage()); }
}
return result;
}
//
// Input data Expression Matrix interface - unfiltered, unchanged, copy of the user provided matrix
//
// for getExpTypeGroupNames, the group names will depend on the experiment type
// ex: TIME_COURSE_SINGLE will be composed of "GroupName T?"
public String[] getExpTypeGroupNames() {
return dataInputMatrix.getExpTypeGroupNames();
}
public int getTimePoints() {
return dataInputMatrix.getTimePoints();
}
public String[] getTimePointNames() {
return dataInputMatrix.getTimePointNames();
}
public String[] getResultNames() {
return dataInputMatrix.getResultNames();
}
public int[] getConditionsSamples() {
int cnt = 0;
int[] scnt = null;
ArrayList<DataInputMatrix.ExpMatrixCondition> lst = dataInputMatrix.getExpressionMatrixConditions();
int conditions = 0;
switch(project.data.getExperimentType()) {
case Two_Group_Comparison:
scnt = new int[lst.size()];
for(DataInputMatrix.ExpMatrixCondition emc : lst)
scnt[conditions++] = emc.nsamples;
break;
case Time_Course_Multiple:
case Time_Course_Single:
// get number of group-time
for(DataInputMatrix.ExpMatrixCondition emc : lst)
cnt += emc.group.lstTimes.size();
scnt = new int[cnt];
for(DataInputMatrix.ExpMatrixCondition emc : lst) {
DlgInputData.Params.ExpMatrixGroup emg = emc.group;
for(DlgInputData.Params.ExpMatrixTime emt : emg.lstTimes)
scnt[conditions++] = emt.lstSampleNames.size();
}
break;
}
return scnt;
}
public int[] getGroupSamples() {
ArrayList<DataInputMatrix.ExpMatrixCondition> lst = dataInputMatrix.getExpressionMatrixConditions();
int conditions = 0;
int[] scnt = new int[lst.size()];
for(DataInputMatrix.ExpMatrixCondition emc : lst)
scnt[conditions++] = emc.nsamples;
return scnt;
}
public int[] getGroupTimes() {
ArrayList<DataInputMatrix.ExpMatrixCondition> lst = dataInputMatrix.getExpressionMatrixConditions();
int grpnum = 0;
//DlgInputData.Params params = new DlgInputData.Params(IDParams);
int[] scnt = new int[params.lstGroups.size()];
for(DlgInputData.Params.ExpMatrixGroup emc : params.lstGroups)
scnt[grpnum++] = emc.lstTimes.size();
return scnt;
}
public int getGroupTimeSamples(int grpnum, int timenum) {
int scnt = 0;
if(grpnum >= 0 && grpnum < params.lstGroups.size()) {
DlgInputData.Params.ExpMatrixGroup emc = params.lstGroups.get(grpnum);
if(timenum >= 0 && timenum < emc.lstTimes.size()) {
DlgInputData.Params.ExpMatrixTime emt = emc.lstTimes.get(timenum);
scnt = emt.lstSampleNames.size();
}
}
return scnt;
}
public String[] getGroupNames() {
return dataInputMatrix.getGroupNames();
}
public int getGroupsCount() {
return dataInputMatrix.getGroupNames().length;
}
public String[] getGroupsTimeNames() {
return dataInputMatrix.getGroupsTimeNames();
}
public String[] getGroupTimeNames(int grpnum) {
return dataInputMatrix.getGroupTimeNames(grpnum);
}
public int getGroupTimesCount(int grpnum) {
return dataInputMatrix.getGroupTimeNames(grpnum).length;
}
/*
public String getConditionName(int num) {
String name = "";
if(num >= 1 && num <= 2) {
name = "Condition " + num;
if(IDParams != null) {
if(IDParams.containsKey("condition" + num))
name = IDParams.get("condition" + num);
}
}
return name;
}*/
public DataInputMatrix.ExpMatrixParams getInputMatrixParams() {
return(dataInputMatrix.getInputMatrixParams());