-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOTUStalkerGUI_UI.java
1703 lines (1523 loc) · 87.9 KB
/
OTUStalkerGUI_UI.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
/*
* Copyright (c) 2015, Z. A. Dyson ([email protected]) & L. B. M. Speirs
* Last updated May 27 2015
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* my.outstalkergui is a GUI version of the program OTUStalker designed for
* filtering PCR amplicon data by organism of interest.
*/
package my.otustalkergui;
import java.awt.Component;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
/**
* OTUStalkerGUI - Graphical User Interface (GUI) version of OTUStalker a
* program designed to filter PCR amplicon data by organism
*
* @author Z. A. Dyson & L. B. M. Speirs
* @version 0.0.1
*
*/
public class OTUStalkerGUI_UI extends javax.swing.JFrame {
private static Component frame;
boolean filesSelected = false;
File workingDirectory;
/**
* Creates new form OTUStalkerGUI_UI for GUI for OTUStalker program
*/
public OTUStalkerGUI_UI() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jButtonCancelOTUSTalker = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jLabel11 = new javax.swing.JLabel();
jToolBar1 = new javax.swing.JToolBar();
jButtonRunOTUStalker = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jTextFieldOrganism = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextAreaOTUStalkerOutput = new javax.swing.JTextArea();
jTextFieldTaxAssign = new javax.swing.JTextField();
jButtonTaxAssign = new javax.swing.JButton();
jSeparator1 = new javax.swing.JSeparator();
jLabel3 = new javax.swing.JLabel();
jProgressBar = new javax.swing.JProgressBar();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jTextFieldOTUList = new javax.swing.JTextField();
label1 = new java.awt.Label();
jButtonOTUList = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
jTextFieldDeMulSeq = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
jTextFieldReadData = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
jTextFieldReadScores = new javax.swing.JTextField();
jButtonDeMulSeq = new javax.swing.JButton();
jButtonReadData = new javax.swing.JButton();
jButtonReadScores = new javax.swing.JButton();
jLabel9 = new javax.swing.JLabel();
jSeparator2 = new javax.swing.JSeparator();
jLabel10 = new javax.swing.JLabel();
jTextFieldOutputDir = new javax.swing.JTextField();
jButtonOutputDir = new javax.swing.JButton();
jButtonQuit = new javax.swing.JButton();
jLabel12 = new javax.swing.JLabel();
jTextFieldRepSeq = new javax.swing.JTextField();
jButtonRepSeq = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jButton1.setText("jButton1");
jButtonCancelOTUSTalker.setText("Cancel");
jButtonCancelOTUSTalker.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonCancelOTUSTalkerActionPerformed(evt);
}
});
jScrollPane2.setViewportView(jTextPane1);
jLabel11.setText("Time elapsed during run:");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("OTUStalker ");
setResizable(false);
jToolBar1.setRollover(true);
jButtonRunOTUStalker.setText("Start OTUStalking");
jButtonRunOTUStalker.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonRunOTUStalkerActionPerformed(evt);
}
});
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel1.setText("Organism of interest ");
jLabel1.setToolTipText("A single nominated taxonomic group of interest. Query term is not case sensitive.");
jTextFieldOrganism.setText("e.g. Chloroflexi");
jTextFieldOrganism.setToolTipText("A single nominated taxonomic group of interest. Query term is not case sensitive.");
jTextFieldOrganism.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextFieldOrganismActionPerformed(evt);
}
});
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel2.setText("Taxonomic Assignment file ");
jLabel2.setToolTipText("<html>This text file contains a line for each OTU created.<br> Each line then lists an OTU identifier followed by <br> its taxonomic assignment. This file<br> (eg: seqs_rep_set_tax_assignments.txt) is<br> generated by the script “assign_taxonomy.py”.</html>");
jTextAreaOTUStalkerOutput.setColumns(20);
jTextAreaOTUStalkerOutput.setRows(5);
jTextAreaOTUStalkerOutput.setText("Awaiting organism and file information...");
jTextAreaOTUStalkerOutput.setAutoscrolls(false);
jScrollPane1.setViewportView(jTextAreaOTUStalkerOutput);
jTextFieldTaxAssign.setText("e.g. seqs_rep_set_tax_assignments.txt");
jTextFieldTaxAssign.setToolTipText("<html>This text file contains a line for each OTU created.<br>\n Each line then lists an OTU identifier followed by <br>\nits taxonomic assignment. This file<br>\n (eg: seqs_rep_set_tax_assignments.txt) is<br>\n generated by the script “assign_taxonomy.py”.</html>");
jTextFieldTaxAssign.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextFieldTaxAssignActionPerformed(evt);
}
});
jButtonTaxAssign.setText("Select");
jButtonTaxAssign.setToolTipText("<html>This text file contains a line for each OTU created.<br> Each line then lists an OTU identifier followed by <br> its taxonomic assignment. This file<br> (eg: seqs_rep_set_tax_assignments.txt) is<br> generated by the script “assign_taxonomy.py”.</html>");
jButtonTaxAssign.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonTaxAssignActionPerformed(evt);
}
});
jLabel3.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
jLabel3.setText("OTUStalker Run Status:");
jProgressBar.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
jProgressBar.setStringPainted(true);
jLabel4.setText("Progress");
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel5.setText("OTU Sequence List file ");
jTextFieldOTUList.setText("e.g. seqs_otus.txt");
jTextFieldOTUList.setToolTipText("<html>\nThis file contains a list of all the representative OTU <br> \nidentifiers and the corresponding individual sequences <br>\nthat contribute to each. This file is generated by the script <br>\n“pick_de_novo_otus.py” (or one of the alternative OTU<br>\npicking methods).");
label1.setText("Demultiplexed sequences file");
jButtonOTUList.setText("Select");
jButtonOTUList.setToolTipText("<html>\nThis file contains a list of all the representative OTU <br> \nidentifiers and the corresponding individual sequences <br>\nthat contribute to each. This file is generated by the script <br>\n“pick_de_novo_otus.py” (or one of the alternative OTU<br>\npicking methods).");
jButtonOTUList.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonOTUListActionPerformed(evt);
}
});
jLabel6.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
jLabel6.setText("Select your files, and enter the name of your organism of intestet below:");
jTextFieldDeMulSeq.setText("e.g. seqs.fna");
jTextFieldDeMulSeq.setToolTipText("<html>\nThe script “split_libraries.py” will parse and rename <br> \neach read provided by the sequencing platform, with <br> \nthe appropriate Sample ID, therefore formatting the <br> \nsequence data for downstream analysis. This script <br> \ngenerates a file with the default name “seqs.fna”.");
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel7.setText("Read data file ");
jTextFieldReadData.setText("e.g. HYPIJKO01.fna");
jTextFieldReadData.setToolTipText("<html>\nThis is the pyrosequencing platform generated <br> \nFASTA file (eg: ABCD.fna). The amplicon processing <br> \nsoftware attached to the pyrosequencing platform will <br>\ngenerate one of these files for each region of the PTP plate. ");
jTextFieldReadData.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextFieldReadDataActionPerformed(evt);
}
});
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel8.setText("Read quality scores file ");
jTextFieldReadScores.setText("e.g. HYPIJKO01.qual");
jTextFieldReadScores.setToolTipText("<html>\nThis is the pyrosequencing platform generated <br>\nquality score file (eg: ABCD.qual), which contains<br>\na quality score for each base of each sequence<br>\nincluded in the FASTA (ie: ABCD.fna) file. Like the <br>\nfasta file mentioned above, the amplicon processing <br>\nsoftware will generate one of these files for each <br>\nregion of the PTP plate.");
jButtonDeMulSeq.setText("Select");
jButtonDeMulSeq.setToolTipText("<html>\nThe script “split_libraries.py” will parse and rename <br> \neach read provided by the sequencing platform, with <br> \nthe appropriate Sample ID, therefore formatting the <br> \nsequence data for downstream analysis. This script <br> \ngenerates a file with the default name “seqs.fna”.");
jButtonDeMulSeq.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonDeMulSeqActionPerformed(evt);
}
});
jButtonReadData.setText("Select");
jButtonReadData.setToolTipText("<html>\nThis is the pyrosequencing platform generated <br> \nFASTA file (eg: ABCD.fna). The amplicon processing <br> \nsoftware attached to the pyrosequencing platform will <br>\ngenerate one of these files for each region of the PTP plate. ");
jButtonReadData.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonReadDataActionPerformed(evt);
}
});
jButtonReadScores.setText("Select");
jButtonReadScores.setToolTipText("<html>\nThis is the pyrosequencing platform generated <br>\nquality score file (eg: ABCD.qual), which contains<br>\na quality score for each base of each sequence<br>\nincluded in the FASTA (ie: ABCD.fna) file. Like the <br>\nfasta file mentioned above, the amplicon processing <br>\nsoftware will generate one of these files for each <br>\nregion of the PTP plate.");
jButtonReadScores.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonReadScoresActionPerformed(evt);
}
});
jLabel9.setFont(new java.awt.Font("Lucida Grande", 1, 14)); // NOI18N
jLabel9.setText("Welcome to OTUStalker, a program designed to filter PCR amplicon data by organism!");
jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel10.setText("Output directory ");
jLabel10.setToolTipText("File path nominated by the OTUStalker user.");
jTextFieldOutputDir.setText("e.g. /home/speirs_dyson/putmydatahere/");
jTextFieldOutputDir.setToolTipText("File path nominated by the OTUStalker user.");
jTextFieldOutputDir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextFieldOutputDirActionPerformed(evt);
}
});
jButtonOutputDir.setText("Select");
jButtonOutputDir.setToolTipText("File path nominated by the OTUStalker user");
jButtonOutputDir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonOutputDirActionPerformed(evt);
}
});
jButtonQuit.setText("Quit");
jButtonQuit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonQuitActionPerformed(evt);
}
});
jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel12.setText("Representative sequences file");
jTextFieldRepSeq.setText("e.g. seqs_rep_set.fasta");
jTextFieldRepSeq.setToolTipText("<html>\nThis file is created by the “pick_rep_set.py”.<br>\nIt is a FASTA file containing one sequence per <br>\nOTU. The default name of the output file will <br>\nbe (input_sequences_filepath)_rep_set.fasta.");
jTextFieldRepSeq.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextFieldRepSeqActionPerformed(evt);
}
});
jButtonRepSeq.setText("Select");
jButtonRepSeq.setToolTipText("<html>\nThis file is created by the “pick_rep_set.py”.<br>\nIt is a FASTA file containing one sequence per <br>\nOTU. The default name of the output file will <br>\nbe (input_sequences_filepath)_rep_set.fasta.");
jButtonRepSeq.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonRepSeqActionPerformed(evt);
}
});
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator2)
.addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel9)
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 498, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGap(15, 15, 15)
.addComponent(jLabel2))
.addGroup(layout.createSequentialGroup()
.addGap(54, 54, 54)
.addComponent(jLabel5)
.addGap(327, 327, 327)
.addComponent(jButtonOTUList))
.addGroup(layout.createSequentialGroup()
.addGap(62, 62, 62)
.addComponent(jLabel1)
.addGap(0, 0, 0)
.addComponent(jTextFieldOrganism, javax.swing.GroupLayout.PREFERRED_SIZE, 327, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(87, 87, 87)
.addComponent(jLabel10)
.addGap(0, 0, 0)
.addComponent(jTextFieldOutputDir, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(3, 3, 3)
.addComponent(jButtonOutputDir)))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane1)
.addGap(6, 6, 6))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addComponent(jProgressBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jButtonRunOTUStalker)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButtonQuit))
.addComponent(jLabel3))
.addGap(0, 0, Short.MAX_VALUE)))
.addGap(6, 6, 6))))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(jTextFieldTaxAssign, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(3, 3, 3)
.addComponent(jButtonTaxAssign))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jTextFieldOTUList, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(103, 103, 103)
.addComponent(jLabel7))
.addGroup(layout.createSequentialGroup()
.addGap(42, 42, 42)
.addComponent(jLabel8)))
.addGap(0, 0, 0)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextFieldDeMulSeq, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jTextFieldReadData)
.addComponent(jTextFieldReadScores, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel12)
.addGap(0, 2, Short.MAX_VALUE)
.addComponent(jTextFieldRepSeq, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(3, 3, 3)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButtonReadData)
.addComponent(jButtonDeMulSeq)
.addComponent(jButtonReadScores)))
.addGroup(layout.createSequentialGroup()
.addGap(3, 3, 3)
.addComponent(jButtonRepSeq)))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(12, 12, 12)
.addComponent(jLabel9)
.addGap(18, 18, 18)
.addComponent(jLabel6)
.addGap(14, 14, 14)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jTextFieldOrganism, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextFieldOutputDir, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10)
.addComponent(jButtonOutputDir))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jTextFieldTaxAssign, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonTaxAssign))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextFieldRepSeq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12)
.addComponent(jButtonRepSeq))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonOTUList)
.addComponent(jTextFieldOTUList, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextFieldDeMulSeq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonDeMulSeq))
.addComponent(label1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextFieldReadData, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonReadData)
.addComponent(jLabel7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextFieldReadScores, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButtonReadScores)
.addComponent(jLabel8))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonRunOTUStalker)
.addComponent(jButtonQuit))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(16, 16, 16)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(jProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(12, Short.MAX_VALUE))
);
label1.getAccessibleContext().setAccessibleName("Select file 3");
pack();
}// </editor-fold>
private void jButtonRunOTUStalkerActionPerformed(java.awt.event.ActionEvent evt) {
new Thread(new otustalkerthread1()).start();
jButtonRunOTUStalker.setEnabled(false);
}
private void jButtonTaxAssignActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser taxAssignChooser = new JFileChooser();
if (filesSelected == true) {
taxAssignChooser.setCurrentDirectory(workingDirectory);
}
taxAssignChooser.showOpenDialog(null);
File taxAssignFile = taxAssignChooser.getSelectedFile();
if (taxAssignFile != null) {
String taxAssignFilename = taxAssignFile.getAbsolutePath();
workingDirectory = taxAssignChooser.getCurrentDirectory();
jTextFieldTaxAssign.setText(taxAssignFilename);
filesSelected = true;
}
}
private void jButtonCancelOTUSTalkerActionPerformed(java.awt.event.ActionEvent evt) {
}
private void jTextFieldOrganismActionPerformed(java.awt.event.ActionEvent evt) {
}
private void jButtonDeMulSeqActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser deMulSeqChooser = new JFileChooser();
if (filesSelected == true) {
deMulSeqChooser.setCurrentDirectory(workingDirectory);
}
deMulSeqChooser.showOpenDialog(null);
File deMulSeqFile = deMulSeqChooser.getSelectedFile();
if (deMulSeqFile != null) {
String deMulSeqFilename = deMulSeqFile.getAbsolutePath();
workingDirectory = deMulSeqChooser.getCurrentDirectory();
jTextFieldDeMulSeq.setText(deMulSeqFilename);
filesSelected = true;
}
}
private void jTextFieldReadDataActionPerformed(java.awt.event.ActionEvent evt) {
}
private void jTextFieldTaxAssignActionPerformed(java.awt.event.ActionEvent evt) {
}
private void jButtonOTUListActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser otuListChooser = new JFileChooser();
if (filesSelected == true) {
otuListChooser.setCurrentDirectory(workingDirectory);
}
otuListChooser.showOpenDialog(null);
File otuListFile = otuListChooser.getSelectedFile();
if (otuListFile != null) {
String otuListFilename = otuListFile.getAbsolutePath();
workingDirectory = otuListChooser.getCurrentDirectory();
jTextFieldOTUList.setText(otuListFilename);
filesSelected = true;
}
}
private void jButtonReadScoresActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser readScoresChooser = new JFileChooser();
if (filesSelected == true) {
readScoresChooser.setCurrentDirectory(workingDirectory);
}
readScoresChooser.showOpenDialog(null);
File readScoresFile = readScoresChooser.getSelectedFile();
if (readScoresFile != null) {
String readScoresFilename = readScoresFile.getAbsolutePath();
workingDirectory = readScoresChooser.getCurrentDirectory();
jTextFieldReadScores.setText(readScoresFilename);
filesSelected = true;
}
}
private void jButtonOutputDirActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser outputDirectoryChooser = new JFileChooser();
if (filesSelected == true) {
outputDirectoryChooser.setCurrentDirectory(workingDirectory);
}
outputDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
outputDirectoryChooser.setAcceptAllFileFilterUsed(false);
outputDirectoryChooser.showOpenDialog(null);
File outputDirectoryFile = outputDirectoryChooser.getSelectedFile();
if (outputDirectoryFile != null) {
String outputDirectoryFilename = outputDirectoryFile.getAbsolutePath();
workingDirectory = outputDirectoryChooser.getCurrentDirectory();
jTextFieldOutputDir.setText(outputDirectoryFilename);
filesSelected = true;
}
}
private void jTextFieldOutputDirActionPerformed(java.awt.event.ActionEvent evt) {
}
private void jButtonQuitActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void jButtonReadDataActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser readDataChooser = new JFileChooser();
if (filesSelected == true) {
readDataChooser.setCurrentDirectory(workingDirectory);
}
readDataChooser.showOpenDialog(null);
File readDataFile = readDataChooser.getSelectedFile();
if (readDataFile != null) {
String readDataFilename = readDataFile.getAbsolutePath();
workingDirectory = readDataChooser.getCurrentDirectory();
jTextFieldReadData.setText(readDataFilename);
filesSelected = true;
}
}
private void jButtonRepSeqActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser repSeqChooser = new JFileChooser();
if (filesSelected == true) {
repSeqChooser.setCurrentDirectory(workingDirectory);
}
repSeqChooser.showOpenDialog(null);
File repSeqFile = repSeqChooser.getSelectedFile();
if (repSeqFile != null) {
String repSeqFilename = repSeqFile.getAbsolutePath();
workingDirectory = repSeqChooser.getCurrentDirectory();
jTextFieldRepSeq.setText(repSeqFilename);
filesSelected = true;
}
}
private void jTextFieldRepSeqActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(OTUStalkerGUI_UI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(OTUStalkerGUI_UI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(OTUStalkerGUI_UI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(OTUStalkerGUI_UI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new OTUStalkerGUI_UI().setVisible(true);
}
});
}
/**
* Retrieve the OTU numbers, and proportion of the organism of interest
* present, and number of representative sequences from the input data files
*
* @param outputDate Date of OTUStalker run
* @param searchOrganism the organism of interest, will be searched case
* independently
* @param repSet filename of taxonomic assignments file
* @param repSeq filename of the representative sequences file
* @param outputDir location of output directory selected by user
*
* @return finalResults total number of organisms, number of organism of
* interest, and the number of OTU representative sequences retrieved
*/
public static int[] getOrganismOTUNumsAndRepSeqs(
String outputDate, String searchOrganism, String repSet,
String repSeq, String outputDir) {
//Initialize variables
int organismCount = 0;
int totalOrganismCount = 0;
int seqMatchCount = 0;
String taxassignments;
try {
//Open data files
BufferedReader speciesDataIn = new BufferedReader(
new FileReader(repSet));
//Create output files
PrintWriter taxAssignDataOut = new PrintWriter(
new FileWriter(outputDir + outputDate
+ "_" + searchOrganism + "_Output/"
+ searchOrganism + "TaxAssignData.txt"));
PrintWriter repOTUListOut = new PrintWriter(
new FileWriter(outputDir + outputDate + "_"
+ searchOrganism + "_Output/"
+ searchOrganism + "OTUNumbers.txt"));
PrintWriter repSeqDataOut = new PrintWriter(
new FileWriter(outputDir + outputDate
+ "_" + searchOrganism + "_Output/All"
+ searchOrganism + "RepOTUs.fasta"));
//While there are new entries in the data file, keep screening
while ((taxassignments = speciesDataIn.readLine()) != null) {
totalOrganismCount++;
//Delimit file for screening
String splitarray[] = taxassignments.split("\t");
String taxassignotunumber = splitarray[0];
String secondentry = splitarray[1];
/*regular expression to search organism name regardless of lower
or upper case*/
boolean chloroflexiMatch = false;
if (secondentry.matches("(?i).*" + "_" + searchOrganism + ";" + ".*") || secondentry.matches("(?i).*" + "_" + searchOrganism)) {
chloroflexiMatch = true;
};
/*If the entry corresponds to the desired organism append
the entry to the output file and obtain representative sequence
data and output data*/
if (chloroflexiMatch) {
organismCount++;
/*Output taxonomic data and OTU numbers pertaining to the
organism of interest*/
taxAssignDataOut.println(taxassignments);
repOTUListOut.println(taxassignotunumber);
//Initalize variable for looping
String newToken;
boolean seqFound = false;
/* Open representative sequences data file and
retrieve relevant data */
Scanner repSeqIn = new Scanner(
new File(repSeq));
repSeqIn.useDelimiter(">");
StringBuffer tokenAdder = new StringBuffer();
while (repSeqIn.hasNext() && !seqFound) {
tokenAdder.append(repSeqIn.next());
newToken = tokenAdder.toString();
String splitarray2[] = newToken.split(" ");
String repfileotunumber = splitarray2[0];
if (repfileotunumber.matches(taxassignotunumber)) {
seqMatchCount++;
repSeqDataOut.append(
">" + tokenAdder.toString());
seqFound = true;
}
tokenAdder.delete(0, tokenAdder.length());
}
//Close scanner
repSeqIn.close();
}
}
//Close files
repOTUListOut.close();
repSeqDataOut.close();
taxAssignDataOut.close();
speciesDataIn.close();
//Exception handling
} catch (IOException ex) {
JOptionPane.showMessageDialog(frame,
"Taxonomic assignment or representative sequences "
+ "\nfiles not found, or output directory not selected"
+ "\nplease check these and try again.");
} catch (ArrayIndexOutOfBoundsException ex) {
JOptionPane.showMessageDialog(frame,
"Taxonimic assignment or representative sequences input"
+ " \nfile(s) format is not correct, please check file"
+ " format and try again.");
}
int[] finalResults = new int[]{
totalOrganismCount, organismCount, seqMatchCount};
return finalResults;
}
/**
* Retrieve sequence names for all OTUs pertaining to organism of interest
*
* @param outputDate Date of OTUStalker run
* @param searchOrganism the organism of interest, will be searched case
* independently
* @param seqsOTUs filename of OTU sequence list file
* @param outputDir location of output directory selected by user
*
* @return finalResults the number of matched OTUs, and the number of
* sequence names retrieved
*/
public static int[] getOTUSequenceNames(
String outputDate, String searchOrganism,
String seqsOTUs, String outputDir) {
//Initialize variables and data structures
int matchedOTUCount = 0;
int countSeqNamesListed = 0;
PrintWriter sequenceNamesOut;
try {
//Open data files and initialize output files
BufferedReader otuSequenceListIn = new BufferedReader(
new FileReader(seqsOTUs));
String otuSequenceList;
sequenceNamesOut = new PrintWriter(
new FileWriter(outputDir + outputDate + "_"
+ searchOrganism + "_Output/"
+ searchOrganism + "SequenceNames.txt"));
//While there are new entries in the data file, keep screening
while ((otuSequenceList = otuSequenceListIn.readLine()) != null) {
//Boolean for exiting while loop when a sequence name is located
boolean otuFound = false;
//Delimit the current entry by tab
String splitarray[] = otuSequenceList.split("\t");
String otuNumber = splitarray[0];
//Open data file
BufferedReader otuListIn = new BufferedReader(
new FileReader(
outputDir + outputDate + "_" + searchOrganism
+ "_Output/" + searchOrganism
+ "OTUNumbers.txt"));
String otuListEntry;
//Read through list of selected OTU numbers and attempt to match
//to the current entry in the seqs_otus data file
while ((otuListEntry = otuListIn.readLine()) != null
&& !otuFound) {
//If a match is found, output to data file and exit while loop
if (otuListEntry.matches(otuNumber)) {
matchedOTUCount++;
otuFound = true;
//Add all matching sequence names to the data file
int endOfArray = splitarray.length;
countSeqNamesListed = countSeqNamesListed
+ (endOfArray - 1);
for (int i = 1; i < endOfArray; i++) {
sequenceNamesOut.println(splitarray[i]);
}
}
}
}
//close files
sequenceNamesOut.close();
otuSequenceListIn.close();
//Exception handling
} catch (IOException ex) {
JOptionPane.showMessageDialog(frame,
"OTU Sequence List input file not found,\n"
+ "or output directory not selected"
+ "\nplease check these and try again.");
} catch (ArrayIndexOutOfBoundsException ex) {
JOptionPane.showMessageDialog(frame,
"OTU Sequence List input file format is not "
+ "\ncorrect, please check file format and try again.");
}
int[] finalResults = new int[]{matchedOTUCount, countSeqNamesListed};
return finalResults;
}
/**
* Retrieve all read names pertaining to organism of interest
*
* @param outputDate date of OTUStalker run
* @param searchOrganism organism of interest
* @param deMulSeq filename of demultiplexed sequences file
* @param outputDir location of output directory selected by user
* @return matchCount number of OTU numbers matched
*/
public static int getAllOTUReadNumbers(
String outputDate, String searchOrganism,
String deMulSeq, String outputDir) {
//Initialize counter
int matchCount = 0;
try {
//Initialize output files
PrintWriter otuSequenceDataOut = new PrintWriter(
new FileWriter(outputDir + outputDate
+ "_" + searchOrganism + "_Output/All"
+ searchOrganism + "OTUSequenceDataSEQS.fasta"));
PrintWriter otuSequenceReadTagsOut = new PrintWriter(
new FileWriter(outputDir + outputDate + "_"
+ searchOrganism + "_Output/All"
+ searchOrganism + "OTUReadNumbers.txt"));
//Open file seqs.fna and delimit entries by sequence
Scanner scanner2 = new Scanner(new File(deMulSeq));
scanner2.useDelimiter(">");
//While there are more entries in the data file, keep screening
while (scanner2.hasNext()) {
String newToken = scanner2.next().toString();
/* Boolean to allow exiting of loop when a match is found*/
Boolean sequenceFound = false;
//Select the read number from the entry
String scanner2Text = newToken;
String splitarray[] = scanner2Text.split("\n");
String firstentry = splitarray[0];
String splitarray2[] = firstentry.split(" ");
String firstentry2 = splitarray2[0];
String firstentry3 = splitarray2[1];
//Open data file
BufferedReader sequenceNamesIn = new BufferedReader(
new FileReader(
outputDir + outputDate + "_" + searchOrganism
+ "_Output/" + searchOrganism
+ "SequenceNames.txt"));
String nextTag;
/*While a match hasn't been found and there are more entries
in the data file keep reading the file*/
while ((nextTag = sequenceNamesIn.readLine()) != null
&& !sequenceFound) {
/*If a matching sequence name is found add the sequence
data and the read number to their respective data files*/
if (nextTag.matches(firstentry2)) {
matchCount++;
sequenceFound = true;
//Append new data to output files
otuSequenceDataOut.println(">" + scanner2Text);
otuSequenceReadTagsOut.println("" + firstentry3);
}
}
//Close file
sequenceNamesIn.close();
}
//Close files
otuSequenceDataOut.close();
otuSequenceReadTagsOut.close();
scanner2.close();
//Exception handling
} catch (IOException ex) {
JOptionPane.showMessageDialog(frame,
"Demultiplexed sequenced input file not found,\n"
+ "or output directory not selected"
+ "\nplease check these and try again.");
} catch (ArrayIndexOutOfBoundsException ex) {
JOptionPane.showMessageDialog(frame,
"Demultiplexed input file format is not "
+ "\ncorrect, please check file format and try again.");
}
return matchCount;
}
/**
* Retrieve all reads pertaining to the organism of interest and split the
* data by sample
*
* @param outputDate date of OTUStalker run
* @param searchOrganism organism of interest
* @param fnaFile filename of the read data file
* @param outputDir location of output directory selected by user
* @return finalResults the sample names and the number of samples present
* in the sequence data
*/
public static ArrayList[] getAllOTUSequences(String outputDate,
String searchOrganism, String fnaFile,
String outputDir) {
//Initialize variables and data structures
int newSampleNum = 1;
ArrayList sampleNames = new ArrayList();
ArrayList numSamples = new ArrayList();
ArrayList[] finalResults = new ArrayList[]{sampleNames, numSamples};
try {
//initialize variables and data structures
Boolean found = false;
int matchCount = 0;
Scanner scanner;
//Create output directory and files