diff --git a/.idea/libraries/Maven__cglib_cglib_3_2_8.xml b/.idea/libraries/Maven__cglib_cglib_3_2_8.xml
new file mode 100644
index 0000000..8284faf
--- /dev/null
+++ b/.idea/libraries/Maven__cglib_cglib_3_2_8.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_google_code_findbugs_annotations_3_0_1.xml b/.idea/libraries/Maven__com_google_code_findbugs_annotations_3_0_1.xml
new file mode 100644
index 0000000..12c6803
--- /dev/null
+++ b/.idea/libraries/Maven__com_google_code_findbugs_annotations_3_0_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_1.xml b/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_1.xml
new file mode 100644
index 0000000..09453c9
--- /dev/null
+++ b/.idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__junit_junit_4_12.xml b/.idea/libraries/Maven__junit_junit_4_12.xml
new file mode 100644
index 0000000..d411041
--- /dev/null
+++ b/.idea/libraries/Maven__junit_junit_4_12.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_9_12.xml b/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_9_12.xml
new file mode 100644
index 0000000..ec857e4
--- /dev/null
+++ b/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_9_12.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__net_jcip_jcip_annotations_1_0.xml b/.idea/libraries/Maven__net_jcip_jcip_annotations_1_0.xml
new file mode 100644
index 0000000..d29c82f
--- /dev/null
+++ b/.idea/libraries/Maven__net_jcip_jcip_annotations_1_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_extras_beanshell_bsh_2_0b6.xml b/.idea/libraries/Maven__org_apache_extras_beanshell_bsh_2_0b6.xml
new file mode 100644
index 0000000..3b84834
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_extras_beanshell_bsh_2_0b6.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_2_1.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_2_1.xml
new file mode 100644
index 0000000..b170293
--- /dev/null
+++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_2_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
new file mode 100644
index 0000000..f58bbc1
--- /dev/null
+++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_library_2_1.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_library_2_1.xml
new file mode 100644
index 0000000..3b34e7a
--- /dev/null
+++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_library_2_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_jmock_jmock_2_12_0.xml b/.idea/libraries/Maven__org_jmock_jmock_2_12_0.xml
new file mode 100644
index 0000000..be4daa1
--- /dev/null
+++ b/.idea/libraries/Maven__org_jmock_jmock_2_12_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_jmock_jmock_imposters_2_12_0.xml b/.idea/libraries/Maven__org_jmock_jmock_imposters_2_12_0.xml
new file mode 100644
index 0000000..e6be483
--- /dev/null
+++ b/.idea/libraries/Maven__org_jmock_jmock_imposters_2_12_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_jmock_jmock_junit4_2_12_0.xml b/.idea/libraries/Maven__org_jmock_jmock_junit4_2_12_0.xml
new file mode 100644
index 0000000..d68c568
--- /dev/null
+++ b/.idea/libraries/Maven__org_jmock_jmock_junit4_2_12_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_jmock_jmock_legacy_2_12_0.xml b/.idea/libraries/Maven__org_jmock_jmock_legacy_2_12_0.xml
new file mode 100644
index 0000000..e5d5691
--- /dev/null
+++ b/.idea/libraries/Maven__org_jmock_jmock_legacy_2_12_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_jmock_jmock_testjar_2_12_0.xml b/.idea/libraries/Maven__org_jmock_jmock_testjar_2_12_0.xml
new file mode 100644
index 0000000..6dfd7f9
--- /dev/null
+++ b/.idea/libraries/Maven__org_jmock_jmock_testjar_2_12_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_objenesis_objenesis_3_0_1.xml b/.idea/libraries/Maven__org_objenesis_objenesis_3_0_1.xml
new file mode 100644
index 0000000..8178067
--- /dev/null
+++ b/.idea/libraries/Maven__org_objenesis_objenesis_3_0_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_ow2_asm_asm_7_1.xml b/.idea/libraries/Maven__org_ow2_asm_asm_7_1.xml
new file mode 100644
index 0000000..1d8827d
--- /dev/null
+++ b/.idea/libraries/Maven__org_ow2_asm_asm_7_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 324adc6..0630d8a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,6 +4,10 @@
+
+
+
+
@@ -118,8 +122,8 @@
-
+
@@ -135,6 +139,8 @@
1586298334998
+
+
diff --git a/Course7Informatica.iml b/Course7Informatica.iml
index 74a6872..c564664 100644
--- a/Course7Informatica.iml
+++ b/Course7Informatica.iml
@@ -34,5 +34,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index a47c319..fecd095 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,6 +63,11 @@
mariadb-java-client
2.6.0
+
+ org.jmock
+ jmock-junit4
+ 2.12.0
+
diff --git a/src/main/java/Database/DatabaseManager.java b/src/main/java/Database/DatabaseManager.java
index 330a6d3..8eb1cd5 100644
--- a/src/main/java/Database/DatabaseManager.java
+++ b/src/main/java/Database/DatabaseManager.java
@@ -1,6 +1,7 @@
package Database;
+import orffinder.FastaSequence;
import orffinder.ORF;
import java.sql.*;
@@ -54,35 +55,70 @@ public void makeConnection() throws SQLException {
System.out.println("Failed to create connection to database.");
}
}
+
+
+ /**
+ * TODO translate to java
+ * make hashmap
+ * for orf in selectedOrfs.keys():
+ * if orf.parent in hashmap.keys():
+ * arraylist = hashmap.get(parent)
+ * arraylist.add(orf)
+ * else
+ * make new arralist
+ * arraylist.add(orf)
+ * hashmap.put(orf.parent, arraylist)
+ */
+
+ /**
+ *
+ * @param selected_ORF_list
+ * @throws SQLException
+ */
public void insert(HashMap selected_ORF_list) throws SQLException {
+
Selected_ORFs = selected_ORF_list;
int nRowsInserted = 0;
- System.out.println("amount of orfs" + Selected_ORFs.size());
- for(ORF orf : Selected_ORFs.keySet()){
- int id = orf.parentFastaSequence.SequenceID;
+ System.out.println("amount of orfs selected: " + Selected_ORFs.size());
+
+// for(ORF orf : Selected_ORFs.keySet()){
+// int id = orf.parentFastaSequence.SequenceID; //todo ? problem: if multiple sequences, what do we do?
+// //todo: sort selected orfs into buckets of Sequence:
+// }
- }
for(ORF orf : Selected_ORFs.keySet()){
// all id are auto increment
String ORFtable_ORF_sequence = Selected_ORFs.get(orf);
int ORFtable_start = (int) orf.getCounterStart();
int ORFtable_stop = (int) orf.counterEnd;
- String Sequencetable_header = orf.parentFastaSequence.header;
- String Sequencetable_filename = orf.parentFastaSequence.filename;
- int Sequencetable_orfs_found = orf.parentFastaSequence.completedOrfCount;
- int Sequencetable_length = (int) orf.parentFastaSequence.RealSize;
+ String Sequencetable_header = orf.getParentFastaSequence().header;
+ String Sequencetable_filename = orf.getParentFastaSequence().getFilename();
+ int Sequencetable_orfs_found = orf.getParentFastaSequence().completedOrfCount;
+ int Sequencetable_length = (int) orf.getParentFastaSequence().RealSize;
+
+ if (Sequencetable_filename == null) {
+ Sequencetable_filename = "STILL DOESNT WORK"; //TODO check
+ }
+
+ PreparedStatement preparedStatement = connection.prepareStatement(
+ "INSERT INTO sequence " +
+ "(header,filename,orfs_found,total_length) " +
+ "VALUES (?, ?, ?, ?);");
- PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO sequence (header,filename,orfs_found,total_length) VALUES (?, ?, ?, ?);");
preparedStatement.setString(1, Sequencetable_header);
- preparedStatement.setString(2, "doesnt work"); // TODO: 9-4-2020 file gives null ?? heb het even veranderd om verdere foutmeldingen te vinden
+ preparedStatement.setString(2, Sequencetable_filename); // TODO: 9-4-2020 file gives null ?? heb het even veranderd om verdere foutmeldingen te vinden
preparedStatement.setInt(3, Sequencetable_orfs_found);
preparedStatement.setInt(4, Sequencetable_length);
nRowsInserted += preparedStatement.executeUpdate();
- int last_id = Integer.parseInt(getlatestid()); // TODO: 9-4-2020 make this work
+ int last_id = Integer.parseInt(getlatestid()); // TODO: 9-4-2020 make this work // TODO TRY getLatestIdByHeader (new method, pass seq or header&filename)
+
+ PreparedStatement preparedStatement2 = connection.prepareStatement(
+ "INSERT INTO ORF " +
+ "(Sequence_id, start_position, stop_position, ORF_Sequence ) " +
+ "VALUES (?, ?, ?, ?);");
- PreparedStatement preparedStatement2 = connection.prepareStatement("INSERT INTO ORF (Sequence_id, start_position, stop_position, ORF_Sequence ) VALUES (?, ?, ?, ?);");
preparedStatement2.setInt(1, last_id);
preparedStatement2.setInt(2, ORFtable_start);
preparedStatement2.setInt(3, ORFtable_stop);
@@ -122,7 +158,7 @@ public void update() throws SQLException {
preparedStatement.setInt(1, 200);
preparedStatement.setString(2, "banana");
nRowsUpdated += preparedStatement.executeUpdate();
- System.out.println(String.format("Updated %d row(s) of data.", nRowsUpdated));
+ System.out.println(String.format("Updated %d row(s) of data.", nRowsUpdated)); // todo 12 ORFS -> 16 rows??? 4 -> 8
// NOTE No need to commit all changes to database, as auto-commit is enabled by default.
}
@@ -132,10 +168,10 @@ public void update() throws SQLException {
}
System.out.println("Execution finished.");
}
+
public String getlatestid() throws SQLException {
String outputString = "";
try {
-
Statement statement = connection.createStatement();
ResultSet results = statement.executeQuery("SELECT max(id) FROM sequence ");
while (results.next()) {
@@ -146,10 +182,45 @@ public String getlatestid() throws SQLException {
}
} catch (SQLException e) {
- throw new SQLException("Encountered an error when executing given sql statement", e);
+ throw new SQLException("getlatestid: Encountered an error when executing given sql statement", e);
+ }
+ System.out.println(outputString);
+ return outputString;
+ }
+
+
+ /**
+ * get the latest ID of a sequence from database based on header and filename
+ * @param sequence
+ * @return
+ */
+ public String getLatestIdByHeader(FastaSequence sequence) throws SQLException {
+ return getLatestIdByHeader(sequence.header, sequence.getFilename());
+ }
+
+ public String getLatestIdByHeader(String sequenceHeader, String sequenceFilename) throws SQLException {
+ String outputString = "";
+ try {
+ Statement statement = connection.createStatement();
+ ResultSet results = statement.executeQuery(
+ "select max(id) " +
+ "from Sequence " +
+ "where header like '%'"+sequenceHeader+"'%' " +
+ "and filename like '%'"+sequenceFilename+"'%';");
+
+ while (results.next()) {
+ outputString =
+ String.format(
+ "%s",
+ results.getInt(1));
+
+ }
+ } catch (SQLException e) {
+ throw new SQLException("getLatestIdByHeader: Encountered an error when executing given sql statement", e);
}
System.out.println(outputString);
return outputString;
}
+
}
diff --git a/src/main/java/blast/ORFBlaster.java b/src/main/java/blast/ORFBlaster.java
index 616f7dc..e541709 100644
--- a/src/main/java/blast/ORFBlaster.java
+++ b/src/main/java/blast/ORFBlaster.java
@@ -1,6 +1,7 @@
package blast;
import orffinder.ORF;
+import orffinder.ORFFinder;
import org.biojava.nbio.core.sequence.io.util.IOUtils;
import org.biojava.nbio.ws.alignment.qblast.*;
@@ -42,11 +43,12 @@ public ORFBlaster(String email) {
}
- public void blastORFselection(List orfs) {
+ public void blastORFselection(List orfs, ORFFinder finder) {
-//
-// props.setBlastProgram(BlastProgramEnum.blastp);
-// blastService.
+
+ for ( ORF orf : orfs) {
+
+ }
}
/**
diff --git a/src/main/java/orffinder/FastaSequence.java b/src/main/java/orffinder/FastaSequence.java
index bd7a2be..4e9e2ce 100644
--- a/src/main/java/orffinder/FastaSequence.java
+++ b/src/main/java/orffinder/FastaSequence.java
@@ -1,19 +1,21 @@
package orffinder;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
-public class FastaSequence implements Iterable {
+public class FastaSequence implements Iterable, Serializable {
public final String header;
- public String filename;
+ private String fastaFilename;
public final int SequenceID;
private static int IDIncrement = 0;
final long lineNumber;
final long offset; // in file
public long EndPos;
public long RealSize;
+ private ORFFinder finder;
private ArrayList tablelist;
@@ -22,8 +24,10 @@ public class FastaSequence implements Iterable {
public int completedOrfCount = ORFList.size();
//final ArrayList> ORFTrackers = new ArrayList < ArrayList < ORF >> (3); // if above doesnt work
- public FastaSequence(String filename, String currHeader, int currentTextLine, int position) {
- SequenceID = IDIncrement++;
+ public FastaSequence(ORFFinder finder, String filename, String currHeader, int currentTextLine, int position) {
+ this.SequenceID = IDIncrement++;
+ this.fastaFilename = filename;
+ this.finder = finder;
header = currHeader;
lineNumber = currentTextLine;
offset = position; // in file
@@ -32,7 +36,18 @@ public FastaSequence(String filename, String currHeader, int currentTextLine, in
ORFTrackers[2]= new ArrayList();
}
- public void addNewORF(long position, long charCounter, int modulo) {
+// public FastaSequence(String mock) {
+// if (mock.equals("mock)")) {
+// header = "mocking header";
+// lineNumber = 10;
+// offset = 700;
+// filename = "mockFilename";
+// } else {
+// throw new IllegalArgumentException("mock fastasequence failed");
+// }
+// }
+
+ public void addNewORF(int position, int charCounter, int modulo) {
//ORFTrackers.get(modulo).add(new ORF(position, charCounter)); // for nested arraylist
ORFTrackers[modulo].add(new ORF(position, charCounter, this));
@@ -57,10 +72,19 @@ public long getRealSize() {
return RealSize;
}
+ public ORFFinder getORFFinder() {
+ return finder;
+ }
+
+ public String getFilename() {
+ return fastaFilename;
+ }
+
@Override
public Iterator iterator() {
return ORFList.iterator();
}
+
public ArrayList makeTable_list(){
tablelist = new ArrayList();
int orfIdMaker = 0;
@@ -121,7 +145,7 @@ public String getStatistics() {
statistics.append(" StartCounter=").append(o.getCounterStart());
statistics.append(" EndCounter=").append(o.counterEnd);
statistics.append(" ID: ").append(o.getID());
- statistics.append(" PARENT: ").append(o.parentFastaSequence);
+ statistics.append(" PARENT: ").append(o.getParentFastaSequence());
}
diff --git a/src/main/java/orffinder/ORF.java b/src/main/java/orffinder/ORF.java
index f9c5a59..66f7788 100644
--- a/src/main/java/orffinder/ORF.java
+++ b/src/main/java/orffinder/ORF.java
@@ -8,11 +8,24 @@ public class ORF {
public long counterEnd; // relative counter to dna without the fucking linefeeds
// currently testing
- public FastaSequence parentFastaSequence;
+ private FastaSequence parentFastaSequence;
private int ID;
static int orfsmade = 0;
-public ORF(long position, long charCounter, FastaSequence parent) {
+// public ORF(String mockery) {
+// if (mockery.equals("mock")) {
+// offset = 10;
+// endpos = 23;
+// counterStart = 100;
+// counterEnd = 113;
+// parentFastaSequence = new FastaSequence("mock");
+// } else {
+// throw new IllegalArgumentException("mock ORF failed");
+// }
+//
+// }
+
+public ORF(int position, int charCounter, FastaSequence parent) {
offset = position;
counterStart = charCounter;
@@ -21,26 +34,72 @@ public ORF(long position, long charCounter, FastaSequence parent) {
parentFastaSequence = parent;
ID = orfsmade++;
}
-
- public long getSize() {
- return counterEnd-counterStart;
+
+ public int getLength() {
+ return getSize();
}
+ public int getSize() {
+ return (int) (counterEnd-counterStart);
+ }
+
+
+ /**
+ *
+ * @return int: absolute byte-offset in ansii fasta file
+ */
public int getOffset() {
return (int) offset;
}
+ public int getStartPosInFile() {
+ return getOffset();
+ }
+
+ public int getEndPosInFile() {
+ return (int) getEndpos();
+ }
+
+ public int getStartPosInSequence() {
+ return (int) counterStart;
+ }
+
+ public int getEndPosInSequence() {
+ return (int) counterEnd;
+ }
+
+ @Deprecated
public long getCounterStart() {
return counterStart;
}
- public long getEndpos() {
- return endpos;
+ /**
+ *
+ * @return int: absolute byte-end in ansii fasta file
+ */
+ public int getEndpos() {
+ return (int) endpos;
}
public int getID(){
return ID;
}
+
+ public FastaSequence getParentFastaSequence() {
+ return parentFastaSequence;
+ }
+
+ public String toFastaFormat() {
+ StringBuilder fastaBuilder = new StringBuilder();
+
+ fastaBuilder.append("> ORF:").append(getParentFastaSequence().getFilename()+":");
+
+ fastaBuilder.append(counterStart+":"+counterEnd).append(":"+ (getLength() % 3) + "\n"); // pos and frame!
+ String ORFDNASequnceString = getParentFastaSequence().getORFFinder().getOrf(this);
+ fastaBuilder.append(ORFDNASequnceString).append("\n");
+
+ return fastaBuilder.toString();
+ }
}
diff --git a/src/main/java/orffinder/ORFFinder.java b/src/main/java/orffinder/ORFFinder.java
index d1b3933..927b219 100644
--- a/src/main/java/orffinder/ORFFinder.java
+++ b/src/main/java/orffinder/ORFFinder.java
@@ -49,18 +49,18 @@ public static void main(String[] args) {
}
- public ORFFinder(File file) throws IOException {
- file = file;
- mainRAFile = new RandomAccessFile(file, "r");
- mainFileChannel = mainRAFile.getChannel();
- // mainBuffer = new RandomAccessFile(file, "r").getChannel().map(FileChannel.MapMode.READ_ONLY, 0, mainFileChannel.size()); // as oneliner
- mainBuffer = mainFileChannel.map(FileChannel.MapMode.READ_ONLY, 0, mainFileChannel.size());
- mainBuffer.order(ByteOrder.LITTLE_ENDIAN); // SHOOT ME IN THE FOOT (took ~xxxhours to figure out)
+ public ORFFinder() {
+ // SHOOT ME IN THE FOOT (took ~xxxhours to figure out)
}
- public void setFile(File file) {
+ public void setFile(File file) throws IOException {
this.file = file;
+ mainRAFile = new RandomAccessFile(file, "r");
+ mainFileChannel = mainRAFile.getChannel();
+ // mainBuffer = new RandomAccessFile(file, "r").getChannel().map(FileChannel.MapMode.READ_ONLY, 0, mainFileChannel.size()); // as oneliner
+ mainBuffer = mainFileChannel.map(FileChannel.MapMode.READ_ONLY, 0, mainFileChannel.size());
+ mainBuffer.order(ByteOrder.LITTLE_ENDIAN);
}
@@ -70,11 +70,8 @@ public void setFile(File file) {
* using ordinal values as keys maybe? later?: ATG 658471, TAG 846571, TAA 846565, TGA 847165 (changed use of hashmaps to arraylist for now)
* chars of interest and their ASCII values: (65, A) (84, T) (67, C) (71, G) (62, >)
*/
- public void findOrfs() {
- findOrfs(String.valueOf(file));
- }
- public void findOrfs(String filename) {
+ public void findOrfs() {
// TIME LOGGING
long startTime = System.nanoTime();
@@ -163,7 +160,7 @@ public void findOrfs(String filename) {
} //end while headerbuilder
currentTextLine++;
- currentFastaSequence = new FastaSequence(filename, currHeader.toString(), currentTextLine, position);
+ currentFastaSequence = new FastaSequence(this, file.getName(), currHeader.toString(), currentTextLine, position);
currHeader = null;
fastaSequences.add(currentFastaSequence);
@@ -321,7 +318,7 @@ public String getOrf(ORF orf) {
int c;
StringBuilder dna = new StringBuilder();
- int endpos = (int) orf.getEndpos() + 1;
+ int endpos = orf.getEndpos() + 1;
if (endpos + 1 < mainBuffer.capacity()) {
for (int i = orf.getOffset(); i < endpos; i++) {
// todo change endpos in ORF
@@ -341,11 +338,9 @@ public String getOrf(ORF orf) {
}
- @Deprecated
- public ArrayList getInfoForVisualisation() {
+ public ArrayList getSequences() {
return getFastaSequences();
}
-
public ArrayList getFastaSequences() {
return fastaSequences;
}
diff --git a/src/main/java/orfgui/ORFVisualiser.java b/src/main/java/orfgui/ORFVisualiser.java
index d2a072a..3da6489 100644
--- a/src/main/java/orfgui/ORFVisualiser.java
+++ b/src/main/java/orfgui/ORFVisualiser.java
@@ -493,7 +493,8 @@ public void actionPerformed(ActionEvent e) {
Reader reader = new Reader();
File file = reader.FileChooser();
try {
- orfFinder = new ORFFinder(file);
+ orfFinder = new ORFFinder();
+ orfFinder.setFile(file);
orfFinder.findOrfs();
} catch (IOException ex) {
ex.printStackTrace();
@@ -504,7 +505,7 @@ public void actionPerformed(ActionEvent e) {
} catch (IOException ex) {
ex.printStackTrace();
}
- list = orfFinder.getInfoForVisualisation();
+ list = orfFinder.getFastaSequences();
MakeORFlist();
ORFtable();
//reclist = makeRec();
diff --git a/src/test/java/BlastTests/TestORFBlaster.java b/src/test/java/BlastTests/TestORFBlaster.java
index c75aeb5..9f13cac 100644
--- a/src/test/java/BlastTests/TestORFBlaster.java
+++ b/src/test/java/BlastTests/TestORFBlaster.java
@@ -1,16 +1,52 @@
package BlastTests;
import blast.ORFBlaster;
+import orffinder.FastaSequence;
+import orffinder.ORF;
+import orffinder.ORFFinder;
+import org.jmock.Mockery;
public class TestORFBlaster {
- private static final String SEQUENCE = "ATTATAAACGACATAATCGATCGATGCATGTAATATATATAGCTAGCTAGCAGATGCTAGTCGACGATGATGA";
+ private static final Mockery context = new Mockery();
+ // TODO FIX ILLEGALARGUMENTEXCEPTION :(
public static void main(String[] args) {
+ // set up
+ final ORFFinder finder = context.mock(ORFFinder.class);
+ //context.setDefaultResultForType(ORFFinder.class, "AAAAAAAAATTACHGGG");
- ORFBlaster orfBlaster = new ORFBlaster();
- orfBlaster.blastn(SEQUENCE);
- }
+ final ORFBlaster orfBlaster = new ORFBlaster();
+ FastaSequence sequence = new FastaSequence(finder, "test filename", "test header", 0, 0);
+ ORF orf = new ORF(14, 0, sequence);
+
+ // expectations
+// context.checking(new Expectations() {{
+// oneOf (ORFFinder.class).getOrf(ORF.class); will(returnValue("ATACGAGGCAGTACT"));}
+//
+// });
+ // String fastaString = orf.toFastaFormat();
+ //orfBlaster.blastn(fastaString);
+
+
+ }
+// private static final String SEQUENCE = "ATTATAAACGACATAATCGATCGATGCATGTAATATATATAGCTAGCTAGCAGATGCTAGTCGACGATGATGA";
+//
+// public static void main(String[] args) {
+//
+// Mockery mocky = new Mockery();
+// mocky.checking(new ExpectationBuilder() {
+// @Override
+// public void buildExpectations(Action action, ExpectationCollector expectationCollector) {
+//
+// }
+// });
+// ORFBlaster orfBlaster = new ORFBlaster();
+// ORFFinder finder = new ORFFinder(mocky);
+// FastaSequence = new FastaSequence()
+// ORF = new ORF();
+// orfBlaster.blastn(SEQUENCE);
+// }
}
diff --git a/src/test/java/GUITests/TestORFVis.java b/src/test/java/GUITests/TestORFVis.java
index 9fcb9f4..c854485 100644
--- a/src/test/java/GUITests/TestORFVis.java
+++ b/src/test/java/GUITests/TestORFVis.java
@@ -2,9 +2,15 @@
import orfgui.ORFVisualiser;
+import java.sql.SQLException;
+
public class TestORFVis {
public static void main(String[] args) {
- new ORFVisualiser();
+ try {
+ new ORFVisualiser();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
}
}
diff --git a/src/test/java/HelperTests/TestFastaConverter.java b/src/test/java/HelperTests/TestFastaConverter.java
index 6164668..2a9bb09 100644
--- a/src/test/java/HelperTests/TestFastaConverter.java
+++ b/src/test/java/HelperTests/TestFastaConverter.java
@@ -1,7 +1,6 @@
package HelperTests;
import helpers.FastaConverter;
-import orffinder.FastaSequence;
// todo test setting file somewhere randomly in pc, already existing files, non-text files...
// ... overwrite mode? ... god so many things to account for and we haven't even scraped the surface
@@ -11,9 +10,6 @@ public static void main(String[] args) {
FastaConverter fc = new FastaConverter();
- FastaSequence seq = new FastaSequence("nofilename", "sequence 1", 0, 0);
- seq.EndPos = 100;
- seq.RealSize= 90;
}
}
diff --git a/src/test/java/ORFFinderTests/TestORFFinder.java b/src/test/java/ORFFinderTests/TestORFFinder.java
index dc2bece..4930b06 100644
--- a/src/test/java/ORFFinderTests/TestORFFinder.java
+++ b/src/test/java/ORFFinderTests/TestORFFinder.java
@@ -13,17 +13,18 @@ public class TestORFFinder {
public static void main(String[] args) {
try {
File testfile = new File("src/test/resources/data/Glennie_the_platypus.fa");
- ORFFinder orfFinder = new ORFFinder(testfile);
+ ORFFinder orfFinder = new ORFFinder();
+ orfFinder.setFile(testfile);
orfFinder.findOrfs();//
orfFinder.printStats();
orfFinder.getallOrfs();
- ArrayList bob = orfFinder.getInfoForVisualisation();
-
+ ArrayList bob = orfFinder.getFastaSequences();
for ( FastaSequence sequence : bob ) {
+
int count = 0;
for ( ORF orf : sequence ) {
- System.out.println(orfFinder.getOrf(orf));
+ System.out.println(orf.toFastaFormat());
count++;
if (count > 10) {
break;