Skip to content

Commit

Permalink
Fix for ticket 503254 - ACT was not validating input file arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
kpepper committed Feb 6, 2018
1 parent 4e9118d commit 97bb871
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 18 deletions.
4 changes: 3 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ Version 17

Fixed RT ticket #606061 - Using EBI-Dbfetch on ARTEMIS. Change to DbfetchEntrySource.java due to incorrect regular expression and EBI URL.

Resized splash screen.
Resized splash screen, as it was too small to the accommodate text info.

Added error handling for dnaplotter template file loading in standalone mode.

Added Bioconda recipe. RT ticket #341139 .

Fixed RT ticket #467433 - Genbank DBSOURCE field was not recognised by Artemis. DBLINK was already added.

Fixed RT ticket #503254 - Act doesn't detect if file does not exist.

KNOWN ISSUES:
1) Java JDKs 1.8.0_131 and above have a Swing bug related to overlaying of modal dialogs for Mac OS X: https://bugs.openjdk.java.net/browse/JDK-8179335
2) There is a current bug in htsjdk whereby calls to the queryMate functionality can throw an exception on reads with secondaries and/or supplementals.
Expand Down
2 changes: 1 addition & 1 deletion act
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ usage () {
echo " -DuserplotX=FILE[,FILE2] For sequence 'X' open one or more userplots"
echo " -DloguserplotX=FILE[,FILE2] For sequence 'X' open one or more userplots, take log(data)"
echo " -DbamX=FILE[,FILE2,...] For sequence 'X' open one or more BAM, CRAM, VCF, or BCF files"
echo " -Dchado="h:p/d?u" Get ACT to open this CHADO database"
echo " -Dchado=\"h:p/d?u\" Get ACT to open this CHADO database"
echo " -Dread_only Open CHADO database read-only"
echo "EXAMPLES"
echo " % act"
Expand Down
2 changes: 1 addition & 1 deletion art
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ usage () {
echo " -Dshow_cov_plot Open coverage plot in BamView"
echo " -Dshow_forward_lines=? Hide/show forward frame lines [true,false]"
echo " -Dshow_reverse_lines=? Hide/show reverse frame lines [true,false]"
echo " -Dchado="h:p/d?u" Get Artemis to open this CHADO database"
echo " -Dchado=\"h:p/d?u\" Get Artemis to open this CHADO database"
echo " -Dread_only Open CHADO database read-only"
echo "EXAMPLES"
echo " % art AJ006275.embl"
Expand Down
85 changes: 70 additions & 15 deletions uk/ac/sanger/artemis/components/ActMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
import uk.ac.sanger.artemis.io.SimpleEntryInformation;

import java.awt.event.*;
import java.io.File;
import java.io.IOException;
import java.net.URL;

import javax.swing.JFrame;

/**
Expand Down Expand Up @@ -344,35 +347,87 @@ protected void exit()
{
System.exit(0);
}

/**
* Main entry point for ACT
**/
public static void main(final String [] args)
* Validate the program input arguments and exit
* if they are not valid, displaying an error message(s).
* @param args String array
*/
protected static void validateStartupArguments(final String[] args)
{
final ActMain main_window = new ActMain();
main_window.setVisible(true);

final InputStreamProgressListener progress_listener =
main_window.getInputStreamProgressListener();

if(args.length >= 3)
ActMain.makeMultiComparator(main_window, progress_listener,
args);
boolean valid = true;

if(args.length >= 3)
{
// Make sure the files provided are actually valid as far as possible...
for (String file : args)
{
if (file.startsWith("ftp") || file.startsWith("http"))
{
// web resource
try
{
URL url = new URL(file);
}
catch (Exception e)
{
valid = false;
System.err.println("\nError - " + file + " is not a valid URL.");
}
}
else
{
// normal file
File argFile = new File(file);
if (!argFile.exists() || !argFile.isFile())
{
valid = false;
System.err.println("\nError - " + argFile + " is not a valid file.");
}
}
}

}
else
{
if(args.length != 0)
{
System.err.println("Error - this program needs either no " +
System.err.println("\nError - this program needs either no" +
" arguments or an odd number\n" +
"(3 or more):");
System.err.println(" act sequence_1 comparison_data sequence_2");
System.err.println("or");
System.err.println(" act seq_1 comparison_data_2_v_1 seq_2 comparison_data_3_v_2 seq_3");
System.err.println("or");
System.err.println(" act");
System.exit(1);
valid = false;
}
}

if (!valid)
{
System.exit(1);
}

}

/**
* Main entry point for ACT
**/
public static void main(final String [] args)
{
validateStartupArguments(args);

final ActMain main_window = new ActMain();
main_window.setVisible(true);

final InputStreamProgressListener progress_listener =
main_window.getInputStreamProgressListener();

if(args.length >= 3)
{
ActMain.makeMultiComparator(main_window, progress_listener,
args);
}
}

Expand Down

0 comments on commit 97bb871

Please sign in to comment.