public void run()
    {
	// If the user has supplied some input
	if(input != null)
	{
	    // If the user supplied input is valid
	    if(this.validateParameters())
	    {
		// We Now know the parameters are in principle valid.
		// Some more checks are required, which were not performed before
		// simply for efficiency sake. So we now proceed
		// to automatically classify the data if we can.

		// Load Map
		SOMClassifier classifier = (SOMClassifier)SOMClassifier.read(input.getPathToSavedNetwork());

		// Get the number of attributes that the classifier expects
		int attributes = classifier.getMap().getAttributes();

		System.out.println("Details of classifier loaded:");
		System.out.println(classifier.getStats().toString());
		System.out.println("Number of parameters used by classifier: " + attributes);

		// Get the type of classifier that the user wants to use.
		int classifierChoice = input.getClassifier();
		System.out.println("Using classifier: "+classifierChoice);

		System.out.println("Using classifier: "+classifierChoice);
		System.out.println("\n***********************************\n");

		// Now the user may provide a variety of inputs, either
		// 
		// 1. A file containing raw data
		// 2. A file containing paths to OTHER files that contain raw data
		// 3. A directory path, to a directory containing data files.
		// 4. A list of file paths, passed in from the unix terminal.

		PatternFileProcessor p = new PatternFileProcessor(); // Used to read files etc.

		I_DataSet data; // Used to store the data read in.

		OutputResults out = new OutputResults(); // Used to output the results obtained.
		out.setOutputPath(this.input.getPathToOutputFile());

		// Clear the output file if it exists.
		if(Common.fileExist(this.input.getPathToOutputFile()))
		    Common.fileDelete(this.input.getPathToOutputFile());

		// Has the user given us a file?
		if(Common.fileExist(this.input.getPathToClassificationFile()))
		{
		    //*********************
		    //      Case 1.
		    //*********************
		    System.out.println("CASE 1.");
		    // Is the file a raw data file? If yes, read this file,
		    // and classify the data it contains.
		    if(this.input.getPathToClassificationFile().contains(".dat")) // Raw data file
		    {
			// Read data file, and create an input pattern instance
			// containing the data ready for classification.
			I_InputPattern pattern = p.processPatternFile(this.input.getPathToClassificationFile());

			if(pattern == null)
			{
			    System.out.println("Input data for classification invalid.");
			    return;
			}

			// If the pattern has the same number of attributes as the 
			// map to be used to classify it.
			if(pattern.getDataLength() != attributes)
			    System.out.println("This map cannot be used to classify this data - parameter mismatch.");
			else
			{
			    // Classify the pattern
			    Object[] results = classifier.classify(pattern, input.getClassifier());
			    String classification = (String) results[0].toString();
			    Point winningCoord = (Point) results[1];

			    out.process(pattern, classification,winningCoord); // Write to file.

			    // Finally makes sure output file has details of the classifier used etc
			    out.writeSummaryStatisitics(classifier.getStatistics(),input.getPathToSavedNetwork());
			}
		    }
		    //*********************
		    //      Case 2.
		    //*********************
		    // The input is a file containing links to other files.
		    else
		    {
			System.out.println("CASE 2.");
			// Read the file into a data set object
			data = p.processLinkFile(this.input.getPathToClassificationFile());

			if(data == null)
			{
			    System.out.println("Input data for classification invalid.");
			    return;
			}

			// If the pattern has the same number of attributes as the 
			// map to be used to classify it.
			if(data.getColumns() != attributes)
			    System.out.println("This map cannot be used to classify this data - parameter mismatch.");
			else
			{
			    // For each data file linked to
			    for(int i = 0; i < data.getRows(); i ++)
			    {

				// Classify the pattern
				Object[] results = classifier.classify(data.getDataRow(i), input.getClassifier());
				String classification = (String) results[0].toString();
				Point winningCoord = (Point) results[1];

				out.process(data.getDataRow(i), classification,winningCoord); // Write to file.
			    }

			    // Finally makes sure output file has details of the classifier used etc
			    out.writeSummaryStatisitics(classifier.getStatistics(), input.getPathToSavedNetwork());
			}
		    }		
		}
		//*********************
		//      Case 3.
		//*********************
		// User has provided a directory path.
		else if(Common.isDirectory(this.input.getPathToClassificationFile()))
		{
		    System.out.println("CASE 3.");
		    // Get all the files in the specified directory
		    String[] inputFiles = Common.getFilePaths(this.input.getPathToClassificationFile(),".dat");

		    // If there are files to be processed
		    if(inputFiles.length > 0)
		    {
			// For each file in the directory
			for(int i = 0; i < inputFiles.length; i++)
			{
			    // Create an input pattern object from the file
			    I_InputPattern pattern = p.processPatternFile(inputFiles[i]);

			    if(pattern != null)
			    {

				// If the pattern has the same number of attributes as the 
				// map to be used to classify it.
				if(pattern.getDataLength() != attributes)
				    System.out.println("This map cannot be used to classify this data - parameter mismatch.");
				else
				{
				    // Classify the pattern
				    Object[] results = classifier.classify(pattern, input.getClassifier());
				    String classification = (String) results[0].toString();
				    Point winningCoord = (Point) results[1];

				    out.process(pattern, classification,winningCoord); // Write to file.
				}
			    }
			}

			// Finally makes sure output file has details of the classifier used etc
			out.writeSummaryStatisitics(classifier.getStatistics(), input.getPathToSavedNetwork());
		    }
		}
		//*********************
		//      Case 4.
		//*********************
		// File paths passed in from the unix terminal
		else
		{
		    System.out.println("CASE 4.");
		    // Count unix parameters
		    int unixParams = input.getExtraParams().size();

		    // If there are files to be processed
		    if(this.input.getExtraParams().size() > 0)
		    {
			// For each file in the directory
			for(int i = 0; i < unixParams; i++)
			{
			    if(this.input.getExtraParams().elementAt(i).contains(".dat")) // Raw data file
			    {
				// Create an input pattern object from the file
				I_InputPattern pattern = p.processPatternFile(this.input.getExtraParams().elementAt(i));

				if(pattern != null)
				{

				    // If the pattern has the same number of attributes as the 
				    // map to be used to classify it.
				    if(pattern.getDataLength() != attributes)
					System.out.println("This map cannot be used to classify this data - parameter mismatch.");
				    else
				    {
					// Classify the pattern
					Object[] results = classifier.classify(pattern, input.getClassifier());
					String classification = (String) results[0].toString();
					Point winningCoord = (Point) results[1];

					out.process(pattern,classification,winningCoord); // Write to file.
				    }
				}
			    }
			}

			// Finally makes sure output file has details of the classifier used etc
			out.writeSummaryStatisitics(classifier.getStatistics(), input.getPathToSavedNetwork());
		    }
		}
	    }
	}
	else
	    System.out.println("Error: Command Line input parameters are null");

    }