Java code to remove rows with certain attributes 12-07-2014d1306

2014-12-07

Java code to remove rows with certain attributes 12-07-2014d1306


code found here
"C:\Sync\pDR\2014\2014\12 December\12-07-2014d1307\AddOrRemoveRowsWithCertainFeature"


Basically use the UsefulTools class with this Sandbox class


import java.util.ArrayList;


public class Sandbox


public static void main(String[] args) {
Sandbox sandbox = new Sandbox();




public Sandbox()

UsefulTools useful_tools = new UsefulTools();

String full_filepath= "C:\\Sync\\cnio\\lgdata_DR\\2014\\December\\December\\12-05-2014d1152\\HT Q-FISH analysis 12-05-2014d1152\\plate 1 before removing data less than 3.txt";
String directory = full_filepath.replaceAll("(.+)\\\\(.+)", "$1");
String filename = full_filepath.replaceAll("(.+)\\\\(.+)\\.txt", "$2");

ArrayList lines = useful_tools.storeTextFiletoArrayList(full_filepath);
int number_of_items_removed = 0;

for(int i=0; i<lines.size(); i++)
{
String current_line = lines.get(i).toString();
String string_foci = current_line.replaceAll("(.+?)\t(.+?)\t(.+?)\t(.+?)\t(.+?)\t(.+?)\t(.+?)\t(.+?)\t(.+?)\t.+", "$9");
int int_foci = Integer.valueOf(string_foci);
if(int_foci<3)
{
lines.remove(i);
i--;
number_of_items_removed++;

}
System.out.println("Number of items removed: " + number_of_items_removed);
String output_string = lines.toString().replaceAll(", ", "\r\n");
output_string = output_string.replaceAll("\\", "");
output_string = output_string.replaceAll("\\
", "");

useful_tools.createTextFile(directory, filename+"_foci_removed.txt", output_string);
}

}