1 package compbio.nosql.cassandra;
3 import java.io.BufferedReader;
4 import java.io.IOException;
5 import java.io.InputStreamReader;
6 import java.net.HttpURLConnection;
7 import java.net.MalformedURLException;
9 import java.net.URLConnection;
10 import java.text.ParseException;
11 import java.text.SimpleDateFormat;
12 import java.util.Calendar;
13 import java.util.Date;
15 public class DataParsing {
16 private CassandraCreate cc = new CassandraCreate();
18 public void ParsingTest(String input) {
19 System.out.println("Inserting.....");
25 Calendar cal = Calendar.getInstance();
26 String date = cal.get(Calendar.YEAR) + "/" + cal.get(Calendar.MONTH) + "/" + cal.get(Calendar.DAY_OF_MONTH);
29 URLConnection conn = url.openConnection();
30 BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
33 while ((line = br.readLine()) != null) {
34 if (line.matches(date + "(.*)jp_[^\\s]+")) {
36 table = line.split("\\s+");
38 if (!cc.CheckIP(table[table.length - 1])) {
40 urltable = new URL("http://www.compbio.dundee.ac.uk/www-jpred/results/" +table[table.length - 1]+"/"+table[table.length - 1]+".concise.fasta");
41 HttpURLConnection httpConnection = (HttpURLConnection) urltable.openConnection();
42 if (httpConnection.getResponseCode() > 200) {
47 BufferedReader br1 = new BufferedReader(new InputStreamReader(httpConnection.getInputStream()));
51 while ((lineNext = br1.readLine()) != null) {
52 if (lineNext.equals(">QUERY")) {
53 while (!(lineNext = br1.readLine()).matches(">[^\\s]+"))
55 } else if (lineNext.equals(">jnetpred")) {
56 while (!(lineNext = br1.readLine()).matches(">[^\\s]+"))
61 if (newProt.length() <= 1) {
66 SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
68 String dateInString1 = table[0].substring(0, table[0].indexOf(":"));
73 Date dat1 = formatter.parse(dateInString1);
74 dateWork1 = dat1.getTime();
76 } catch (ParseException e) {
79 cc.InsertData(dateWork1, table[0], table[1], table[2], table[table.length - 1], "OK", "OK", newProt, jnetpred);
80 } catch (IOException e) {
81 // e.printStackTrace();
88 // System.out.println("Match " + count);
89 // System.out.println("Not Match " + countNotM);
90 // System.out.println("Error " + countEr);
91 // System.out.println("No protein " + countEmp);
92 } catch (MalformedURLException e) {
94 } catch (IOException e) {