Map<String, Double> binned = new HashMap<>();
// location of the family file
- final static String FAMILIES = "H:/Desktop/PFAM/Family/SeedFamilies.seed";
+ String families = "H:/Desktop/PFAM/Family/SeedFamilies.seed";
// location of the file containing the family-clan links
final static String FAMILIESTOCLAN = "H:/Desktop/PFAM/Family/Clanlinks.dat";
// location of the HMM file
- final static String HMMS = "H:/Desktop/PFAM/HMMs/Pfam-A.hmm";
+ String hmms = "H:/Desktop/PFAM/HMMs/Pfam-A.hmm";
// suffix for raw file
final static String RAW = "/Raw.csv";
final static String BINNED = "/Binned.csv";
// normalisation scale
- final static double SCALE = 100000;
+ final static double SCALE = 1;
// current position in file
int currentFilePosition = 0;
/**
* Analyses a specified number of families and then saves the data. Before
* analysing the data, the previous saved data will be imported and after
- * analysing this data is exported back into the file.
+ * analysing this, the data is exported back into the file.
*
* @param increments
* The number of families to read before saving.
public void run(int increments, boolean keepRawData) throws IOException
{
keepRaw = keepRawData;
- readPreviousData(currentFolder);
+ try
+ {
+ readPreviousData(currentFolder);
+ BufferedReader posReader = new BufferedReader(
+ new FileReader(currentFolder + "/CurrentPosition.txt"));
+
+ String line = posReader.readLine();
+ posReader.close();
+ currentFilePosition = Integer.parseInt(line);
+ } catch (Exception e)
+ {
+ System.out.println("No previous data found");
+ }
+
+
- BufferedReader posReader = new BufferedReader(
- new FileReader(currentFolder + "/CurrentPosition.txt"));
- String line = posReader.readLine();
- posReader.close();
+ BufferedReader inputSTO = new BufferedReader(new FileReader(families));
+ BufferedReader inputHMM = new BufferedReader(new FileReader(hmms));
- BufferedReader inputSTO = new BufferedReader(new FileReader(FAMILIES));
- BufferedReader inputHMM = new BufferedReader(new FileReader(HMMS));
- currentFilePosition = Integer.parseInt(line);
moveLocationBy(currentFilePosition, inputHMM);
moveLocationBy(currentFilePosition, inputSTO);
}
/**
+ * Analyses all families and then saves the data. Before analysing the data,
+ * the previous saved data will be imported and after analysing this, the data
+ * is exported back into the file.
+ *
+ * @param increments
+ * The number of families to read before saving.
+ * @throws IOException
+ */
+ public void runToEnd(boolean keepRawData) throws IOException
+ {
+ keepRaw = keepRawData;
+ BufferedReader inputSTO = null;
+ BufferedReader inputHMM = null;
+ int size = 0;
+ try
+ {
+ readPreviousData(currentFolder);
+ BufferedReader posReader = new BufferedReader(
+ new FileReader(currentFolder + "/CurrentPosition.txt"));
+
+ String line = posReader.readLine();
+ posReader.close();
+ currentFilePosition = Integer.parseInt(line);
+ readPreviousData(currentFolder);
+
+ inputSTO = new BufferedReader(new FileReader(families));
+ inputHMM = new BufferedReader(new FileReader(hmms));
+ } catch (Exception e)
+ {
+ System.out.println("No or incomplete previous data found");
+ }
+
+
+
+ moveLocationBy(currentFilePosition, inputHMM);
+ moveLocationBy(currentFilePosition, inputSTO);
+
+ int filesRead = 0;
+ int i = 0;
+ inputSTO.mark(20);
+ String check = inputSTO.readLine();
+ inputSTO.reset();
+ while (!"".equals(check) && !" ".equals(check) && check != null)
+ {
+ inputSTO.mark(20);
+ String line = inputSTO.readLine();
+ inputSTO.reset();
+
+ FileParse parserSTO = new FileParse(inputSTO, "",
+ DataSourceType.FILE);
+ readStockholm(parserSTO);
+
+ FileParse parserHMM = new FileParse(inputHMM, "",
+ DataSourceType.FILE);
+ readHMM(parserHMM);
+
+ int count = countValidResidues();
+ processData(count);
+ filesRead++;
+
+ currentFilePosition++;
+ System.out.println(i);
+ i++;
+ inputSTO.mark(20);
+ check = inputSTO.readLine();
+ inputSTO.reset();
+ }
+
+
+ PrintWriter p = new PrintWriter(
+ new File(currentFolder + "/CurrentPosition.txt"));
+ p.print(currentFilePosition);
+ p.close();
+ exportData(currentFolder);
+ raw.clear();
+ binned.clear();
+
+ }
+
+ /**
* Reads the previous data from both files
*
* @param source
{
Scanner scanner = new Scanner(line);
scanner.useDelimiter(",");
- binned.put(scanner.next(), scanner.nextDouble());
+ String key = scanner.next();
+ String value = scanner.next();
+ binned.put(key, Double.valueOf(value));
scanner.close();
line = input.readLine();
}
{
raw.get(i).add(Double.parseDouble(value));
}
+ else
+ {
+ raw.get(i).add(null);
+ }
i++;
}
for (int width = 0; width < sequences.size(); width++)
{
- for (int length = 1; length < hmm.getLength(); length++)
+ for (int length = 1; length < hmm.getLength() + 1; length++)
{
char symbol;
int alignPos;
for (int width = 0; width < sequences.size(); width++)
{
- for (int length = 1; length < hmm.getLength(); length++)
+ for (int length = 1; length < hmm.getLength() + 1; length++)
{
char symbol;
int alignPos;
*/
public void printFam(int index) throws IOException
{
- BufferedReader br = new BufferedReader(new FileReader(FAMILIES));
+ BufferedReader br = new BufferedReader(new FileReader(families));
moveLocationBy(index, br);
*/
public void printHMM(int index) throws IOException
{
- BufferedReader br = new BufferedReader(new FileReader(HMMS));
+ BufferedReader br = new BufferedReader(new FileReader(hmms));
moveLocationBy(index, br);
*/
public void exportFam(int index, String location) throws IOException
{
- BufferedReader br = new BufferedReader(new FileReader(FAMILIES));
+ BufferedReader br = new BufferedReader(new FileReader(families));
moveLocationBy(index, br);
{
String name;
- BufferedReader nameFinder = new BufferedReader(new FileReader(HMMS));
+ BufferedReader nameFinder = new BufferedReader(new FileReader(hmms));
moveLocationBy(index, nameFinder);
String name;
BufferedReader nameFinder = new BufferedReader(
- new FileReader(FAMILIES));
+ new FileReader(families));
moveLocationBy(index, nameFinder);
{
- BufferedReader br = new BufferedReader(new FileReader(HMMS));
+ BufferedReader br = new BufferedReader(new FileReader(hmms));
moveLocationBy(index, br);
{
BufferedReader clanFinder = new BufferedReader(new FileReader(FAMILIESTOCLAN));
BufferedReader familyReader = new BufferedReader(
- new FileReader(FAMILIES));
- BufferedReader hmmReader = new BufferedReader(new FileReader(HMMS));
+ new FileReader(families));
+ BufferedReader hmmReader = new BufferedReader(new FileReader(hmms));
HashMap<String, Integer> clanIndexes = new HashMap<>();
int filePos = 0;
int clanCount = 0;
clanCount++;
}
+
Integer clanI = clanIndexes.get(clanName);
String clanPath = directory + "/Clan" + clanI.toString();
File clanFolder = new File(clanPath);
clanFinder.close();
}
+
+ public String getFamilies()
+ {
+ return families;
+ }
+
+ public void setFamilies(String families)
+ {
+ this.families = currentFolder + families;
+ }
+
+ public String getHmms()
+ {
+ return hmms;
+ }
+
+ public void setHmms(String hmms)
+ {
+ this.hmms = currentFolder + hmms;
+ }
+
+
}