3737import javax .swing .border .EmptyBorder ;
3838import javax .swing .border .TitledBorder ;
3939
40+ import scriptmanager .objects .ToolDescriptions ;
4041import scriptmanager .util .FileSelection ;
4142
4243/**
@@ -61,7 +62,7 @@ public class SortByDistWindow extends JFrame implements ActionListener, Property
6162 ArrayList <File > PeakGFFFiles = new ArrayList <File >();
6263 ArrayList <File > RefBEDFiles = new ArrayList <File >();
6364 ArrayList <File > RefGFFFiles = new ArrayList <File >();
64- private File OUT_DIR = null ;
65+ private File OUT_DIR = new File ( System . getProperty ( "user.dir" )) ;
6566
6667 private JButton btnLoadPeakBed ;
6768 private JButton btnLoadPeakGff ;
@@ -136,10 +137,10 @@ public void propertyChange(PropertyChangeEvent evt) {
136137 } else {
137138 setProgress (0 );
138139 int counter = 0 ;
139- for (File RefBED : RefBEDFiles ) {
140- for (File PeakBED : PeakBEDFiles ) {
140+ for (File RefGFF : RefGFFFiles ) {
141+ for (File PeakGFF : PeakGFFFiles ) {
141142 // Execute script
142- SortByDistOutput output_obj = new SortByDistOutput (RefBED , PeakBED , OUT_DIR , chckbxGzipOutput .isSelected (), true , chckbxMatchStrand .isSelected (), UPSTREAM , DOWNSTREAM );
143+ SortByDistOutput output_obj = new SortByDistOutput (RefGFF , PeakGFF , OUT_DIR , chckbxGzipOutput .isSelected (), true , chckbxMatchStrand .isSelected (), UPSTREAM , DOWNSTREAM );
143144 output_obj .addPropertyChangeListener ("log" , new PropertyChangeListener () {
144145 public void propertyChange (PropertyChangeEvent evt ) {
145146 firePropertyChange ("log" , evt .getOldValue (), evt .getNewValue ());
@@ -161,6 +162,9 @@ public void propertyChange(PropertyChangeEvent evt) {
161162 ioe .printStackTrace ();
162163 } catch (NumberFormatException nfe ) {
163164 JOptionPane .showMessageDialog (null , "Distance bound inputs are invalid!!! They must be formatted like valid integers." );
165+ } catch (Exception e ) {
166+ e .printStackTrace ();
167+ JOptionPane .showMessageDialog (null , ToolDescriptions .UNEXPECTED_EXCEPTION_MESSAGE + e .getMessage ());
164168 }
165169 setProgress (100 );
166170 return null ;
@@ -237,7 +241,7 @@ public SortByDistWindow() {
237241
238242 btnLoadPeakBed .addActionListener (new ActionListener () {
239243 public void actionPerformed (ActionEvent e ) {
240- File [] newBEDFiles = FileSelection .getFiles (fc ,"bed" );
244+ File [] newBEDFiles = FileSelection .getFiles (fc ,"bed" , true );
241245 if (newBEDFiles != null ) {
242246 for (int x = 0 ; x < newBEDFiles .length ; x ++) {
243247 PeakBEDFiles .add (newBEDFiles [x ]);
@@ -267,23 +271,23 @@ public void actionPerformed(ActionEvent arg0) {
267271 sl_bedInputPane .putConstraint (SpringLayout .NORTH , btnRemoveRefBed , 10 , SpringLayout .SOUTH , scrollPaneBedPeak );
268272 sl_bedInputPane .putConstraint (SpringLayout .EAST , btnRemoveRefBed , -5 , SpringLayout .EAST , bedInputPane );
269273
270- JScrollPane scrollPane_Ref = new JScrollPane ();
271- sl_bedInputPane .putConstraint (SpringLayout .NORTH , scrollPane_Ref , 10 , SpringLayout .SOUTH , btnLoadRefBed );
272- //sl_bedInputPane.putConstraint(SpringLayout.SOUTH, scrollPane_Ref , -100, SpringLayout.SOUTH, btnLoadRefBed);
273- sl_bedInputPane .putConstraint (SpringLayout .WEST , scrollPane_Ref , 5 , SpringLayout .WEST , bedInputPane );
274- sl_bedInputPane .putConstraint (SpringLayout .EAST , scrollPane_Ref , -5 , SpringLayout .EAST , bedInputPane );
275- sl_bedInputPane .putConstraint (SpringLayout .SOUTH , scrollPane_Ref , 0 , SpringLayout .SOUTH , bedInputPane );
276- bedInputPane .add (scrollPane_Ref );
274+ JScrollPane scrollPaneBedRef = new JScrollPane ();
275+ sl_bedInputPane .putConstraint (SpringLayout .NORTH , scrollPaneBedRef , 10 , SpringLayout .SOUTH , btnLoadRefBed );
276+ //sl_bedInputPane.putConstraint(SpringLayout.SOUTH, scrollPaneBedRef , -100, SpringLayout.SOUTH, btnLoadRefBed);
277+ sl_bedInputPane .putConstraint (SpringLayout .WEST , scrollPaneBedRef , 5 , SpringLayout .WEST , bedInputPane );
278+ sl_bedInputPane .putConstraint (SpringLayout .EAST , scrollPaneBedRef , -5 , SpringLayout .EAST , bedInputPane );
279+ sl_bedInputPane .putConstraint (SpringLayout .SOUTH , scrollPaneBedRef , 0 , SpringLayout .SOUTH , bedInputPane );
280+ bedInputPane .add (scrollPaneBedRef );
277281
278282 refBEDList = new DefaultListModel <String >();
279283 final JList <String > listRef = new JList <String >(refBEDList );
280284 listRef .setForeground (Color .BLACK );
281285 listRef .setFont (new Font ("Lucida Grande" , Font .PLAIN , 12 ));
282- scrollPane_Ref .setViewportView (listRef );
286+ scrollPaneBedRef .setViewportView (listRef );
283287
284288 btnLoadRefBed .addActionListener (new ActionListener () {
285289 public void actionPerformed (ActionEvent e ) {
286- File [] newBEDFiles = FileSelection .getFiles (fc ,"bed" );
290+ File [] newBEDFiles = FileSelection .getFiles (fc ,"bed" , true );
287291 if (newBEDFiles != null ) {
288292 for (int x = 0 ; x < newBEDFiles .length ; x ++) {
289293 RefBEDFiles .add (newBEDFiles [x ]);
@@ -327,7 +331,7 @@ public void actionPerformed(ActionEvent arg0) {
327331
328332 btnLoadPeakGff .addActionListener (new ActionListener () {
329333 public void actionPerformed (ActionEvent e ) {
330- File [] newGFFFiles = FileSelection .getFiles (fc ,"GFF" );
334+ File [] newGFFFiles = FileSelection .getFiles (fc ,"gff" , true );
331335 if (newGFFFiles != null ) {
332336 for (int x = 0 ; x < newGFFFiles .length ; x ++) {
333337 PeakGFFFiles .add (newGFFFiles [x ]);
@@ -373,7 +377,7 @@ public void actionPerformed(ActionEvent arg0) {
373377
374378 btnLoadRefGff .addActionListener (new ActionListener () {
375379 public void actionPerformed (ActionEvent e ) {
376- File [] newGFFFiles = FileSelection .getFiles (fc ,"GFF" );
380+ File [] newGFFFiles = FileSelection .getFiles (fc ,"gff" , true );
377381 if (newGFFFiles != null ) {
378382 for (int x = 0 ; x < newGFFFiles .length ; x ++) {
379383 RefGFFFiles .add (newGFFFiles [x ]);
@@ -394,7 +398,7 @@ public void actionPerformed(ActionEvent arg0) {
394398 });
395399 gffInputPane .add (btnRemoveReGff );
396400
397- // Search Options
401+ // >>>>> Search Options <<<<<
398402 JPanel pnlSearchOptions = new JPanel ();
399403 sl_contentPane .putConstraint (SpringLayout .NORTH , pnlSearchOptions , 10 , SpringLayout .SOUTH , inputCards );
400404 sl_contentPane .putConstraint (SpringLayout .WEST , pnlSearchOptions , 10 , SpringLayout .WEST , contentPane );
@@ -408,7 +412,7 @@ public void actionPerformed(ActionEvent arg0) {
408412 ttlSearch .setTitleFont (new Font ("Lucida Grande" , Font .ITALIC , 13 ));
409413 pnlSearchOptions .setBorder (ttlSearch );
410414
411- //Initialize upstream restrict distance checkbox and input
415+ // Upstream restrict distance checkbox and input
412416 chckbxRestrictUpstreamDistance = new JCheckBox ("Restrict upstream bound (bp):" );
413417 sl_SearchOptions .putConstraint (SpringLayout .NORTH , chckbxRestrictUpstreamDistance , 0 , SpringLayout .NORTH , pnlSearchOptions );
414418 sl_SearchOptions .putConstraint (SpringLayout .WEST , chckbxRestrictUpstreamDistance , 10 , SpringLayout .WEST , pnlSearchOptions );
@@ -428,7 +432,7 @@ public void itemStateChanged(ItemEvent e) {
428432 }
429433 });
430434
431- //Initialize downstream restrict distance checkbox and input
435+ // Downstream restrict distance checkbox and input
432436 chckbxRestrictDownstreamDistance = new JCheckBox ("Restrict downstream bound (bp):" );
433437 sl_SearchOptions .putConstraint (SpringLayout .NORTH , chckbxRestrictDownstreamDistance , 0 , SpringLayout .SOUTH , chckbxRestrictUpstreamDistance );
434438 sl_SearchOptions .putConstraint (SpringLayout .WEST , chckbxRestrictDownstreamDistance , 0 , SpringLayout .WEST , chckbxRestrictUpstreamDistance );
@@ -455,13 +459,14 @@ public void itemStateChanged(ItemEvent e) {
455459 lblSizeAdmonishment .setFont (new Font ("Dialog" , Font .ITALIC , 12 ));
456460 pnlSearchOptions .add (lblSizeAdmonishment );
457461
462+ // Add strand match selection option
458463 chckbxMatchStrand = new JCheckBox ("Strand matched" );
459464 sl_SearchOptions .putConstraint (SpringLayout .SOUTH , chckbxMatchStrand , 0 , SpringLayout .SOUTH , pnlSearchOptions );
460465 sl_SearchOptions .putConstraint (SpringLayout .EAST , chckbxMatchStrand , 0 , SpringLayout .EAST , pnlSearchOptions );
461466 chckbxMatchStrand .setToolTipText ("Only check peaks that are on the same strand as the RefPT" );
462467 pnlSearchOptions .add (chckbxMatchStrand );
463468
464- // Output Options
469+ // >>>>> Output Options <<<<<
465470 JPanel pnlOutputOptions = new JPanel ();
466471 sl_contentPane .putConstraint (SpringLayout .NORTH , pnlOutputOptions , 0 , SpringLayout .SOUTH , pnlSearchOptions );
467472 sl_contentPane .putConstraint (SpringLayout .WEST , pnlOutputOptions , 10 , SpringLayout .WEST , contentPane );
@@ -475,7 +480,7 @@ public void itemStateChanged(ItemEvent e) {
475480 ttlOutput .setTitleFont (new Font ("Lucida Grande" , Font .ITALIC , 13 ));
476481 pnlOutputOptions .setBorder (ttlOutput );
477482
478- //Initialize output directory
483+ // Output directory
479484 btnOutputDirectory = new JButton ("Output Directory" );
480485 sl_OutputOptions .putConstraint (SpringLayout .NORTH , btnOutputDirectory , 0 , SpringLayout .NORTH , pnlOutputOptions );
481486 sl_OutputOptions .putConstraint (SpringLayout .WEST , btnOutputDirectory , 10 , SpringLayout .WEST , pnlOutputOptions );
@@ -491,6 +496,7 @@ public void actionPerformed(ActionEvent e) {
491496 });
492497 pnlOutputOptions .add (btnOutputDirectory );
493498
499+ // Gzip Output
494500 chckbxGzipOutput = new JCheckBox ("Output GZip" );
495501 sl_OutputOptions .putConstraint (SpringLayout .NORTH , chckbxGzipOutput , 0 , SpringLayout .NORTH , btnOutputDirectory );
496502 sl_OutputOptions .putConstraint (SpringLayout .WEST , chckbxGzipOutput , 10 , SpringLayout .EAST , btnOutputDirectory );
0 commit comments