package tools.commandline;

import java.sql.Timestamp;

import storage.TaxonInvalidatorData;

/**
 * This script invalidates NCBI taxon data
 * 
 * @author Bart Mesuere
 * 
 */
public class TaxonInvalidator {
	// data
	TaxonInvalidatorData data;

	/**
	 * Creates a new taxon invalidator and sets all taxa to valid
	 */
	public TaxonInvalidator() {
		data = new TaxonInvalidatorData();
		System.out.println(new Timestamp(System.currentTimeMillis())
				+ " Setting everything to valid...");
		data.setAllValid();
	}

	/**
	 * Invalidates invalid taxa.
	 */
	public void invalidate() {
		System.out.println(new Timestamp(System.currentTimeMillis()) + " Invalidating...");

		// "other sequences" & "environmental samples"
		data.invalidate("id=28384", true);
		data.invalidate("id=48479", true);

		data.invalidate("name LIKE \"%metagenome\"", true);

		// bad names
		data.invalidate("name LIKE \"%uncultured%\" AND valid_taxon = 1", true);
		data.invalidate("name LIKE \"%unidentified%\" AND valid_taxon = 1", true);
		// data.invalidate("name LIKE \"%unclassified%\" AND valid_taxon = 1",
		// false);
		data.invalidate("name LIKE \"%unspecified%\" AND valid_taxon = 1", true);
		data.invalidate("name LIKE \"%undetermined%\" AND valid_taxon = 1", true);
		data.invalidate("name LIKE \"%sample%\" AND valid_taxon = 1", true);

		// elimination of the strain species
		data.invalidate("name LIKE \"% sp.\" AND rank = \"species\" AND valid_taxon = 1", true);
		data.invalidate("name LIKE \"% genomosp.\" AND rank = \"species\" AND valid_taxon = 1",
				true);
		data.invalidate("name RLIKE \"[0-9]\" AND rank = \"species\" AND valid_taxon = 1", true);

		// data.invalidate("rank = \"species\" AND name LIKE \"% % %\" AND name NOT LIKE \"Candidatus %\"");
		// data.invalidate(
		// "rank = \"genus\" AND name LIKE \"% %\" AND name NOT LIKE \"Candidatus %\"",
		// false);
	}

	/**
	 * This script invalidates NCBI taxon data
	 * 
	 * @param args
	 *            not used
	 */
	public static void main(String[] args) {
		TaxonInvalidator ti = new TaxonInvalidator();
		ti.invalidate();
	}
}

@@ -136,17 +136,16 @@
  data%0A *
- 
 %0A * @aut
@@ -163,17 +163,16 @@
 suere%0A *
- 
 %0A */%0Apub
@@ -787,18 +787,24 @@
 true);%0A%0A
-%09%09
+        
 data.inv
@@ -842,24 +842,214 @@
 e%5C%22%22, true);
+%0A        data.invalidate(%22name LIKE %5C%22%25enrichment culture%25%5C%22%22, true);%0A        data.invalidate(%22name LIKE %5C%22%25mixed culture%25%5C%22%22, true);%0A        data.invalidate(%22name LIKE %5C%22%25library%5C%22%22, true);
 %0A%0A%09%09// bad n
@@ -2116,17 +2116,16 @@
 data%0A%09 *
- 
 %0A%09 * @pa

add species invalidations. Closes #314