Permalink
Please sign in to comment.
Showing
with
25,060 additions
and 0 deletions.
- +7 −0 CHANGES
- +194 −0 CRISPR.java
- +243 −0 CRISPRFinder.java
- +500 −0 CRISPRUtil.java
- +367 −0 DNASequence.java
- +160 −0 FASTAReader.java
- +674 −0 LICENSE
- +65 −0 README
- +168 −0 SearchUtil.java
- +249 −0 minced.java
- 0 t/1crisper.fa
- +22,164 −0 t/Aquifex_aeolicus_VF5.fna
- +23 −0 t/CRISPR.fa
- +30 −0 t/grinder-100bp.fa
- +150 −0 t/grinder-800bp.fa
- +44 −0 t/test.fa
- +22 −0 t/test2.fa
7
CHANGES
| @@ -0,0 +1,7 @@ | ||
| +Revision history for MinCED | ||
| + | ||
| +0.1.0 15-Mar-2011 | ||
| + Initial fork from CRT | ||
| + More robust parsing of FASTA files and support for multiFASTA files | ||
| + Support for finding CRISPRs in datasets with more than one sequence | ||
| + Fixed some compilation warnings |
194
CRISPR.java
| @@ -0,0 +1,194 @@ | ||
| +import java.util.*; | ||
| + | ||
| +public class CRISPR | ||
| +{ | ||
| + private Vector<Integer> repeats; | ||
| + private int repeatLength; | ||
| + | ||
| + public CRISPR() | ||
| + { | ||
| + repeats = new Vector<Integer>(); | ||
| + repeatLength = 0; | ||
| + } | ||
| + | ||
| + public CRISPR(Vector<Integer> positions, int length) | ||
| + { | ||
| + repeats = positions; | ||
| + repeatLength = length; | ||
| + } | ||
| + | ||
| + public Vector repeats() | ||
| + { | ||
| + return repeats; | ||
| + } | ||
| + | ||
| + public int repeatLength() | ||
| + { | ||
| + return repeatLength; | ||
| + } | ||
| + | ||
| + public void setRepeats(Vector<Integer> _repeats) | ||
| + { | ||
| + repeats = _repeats; | ||
| + } | ||
| + | ||
| + public void setRepeatLength(int length) | ||
| + { | ||
| + repeatLength = length; | ||
| + } | ||
| + | ||
| + public int repeatSpacing(int pos1, int pos2) | ||
| + { | ||
| + return Math.abs(repeatAt(pos2) - repeatAt(pos1)); | ||
| + } | ||
| + | ||
| + public void addRepeat(int val) | ||
| + { | ||
| + repeats.addElement(new Integer(val)); | ||
| + } | ||
| + | ||
| + public void insertRepeatAt(int val, int pos) | ||
| + { | ||
| + repeats.insertElementAt(new Integer(val), pos); | ||
| + } | ||
| + | ||
| + public void setRepeatAt(int val, int pos) | ||
| + { | ||
| + repeats.setElementAt(new Integer(val), pos); | ||
| + } | ||
| + | ||
| + public void removeRepeat(int val) | ||
| + { | ||
| + repeats.removeElement(new Integer(val)); | ||
| + } | ||
| + | ||
| + public int repeatAt(int i) | ||
| + { | ||
| + return ((Integer)repeats.elementAt(i)).intValue(); | ||
| + } | ||
| + | ||
| + public int start() | ||
| + { | ||
| + return ((Integer)repeats.firstElement()).intValue(); | ||
| + } | ||
| + | ||
| + public int end() | ||
| + { | ||
| + int lastRepeatBegin = ((Integer)repeats.lastElement()).intValue(); | ||
| + return lastRepeatBegin + repeatLength - 1; | ||
| + } | ||
| + | ||
| + public int firstRepeat() | ||
| + { | ||
| + return ((Integer)repeats.elementAt(0)).intValue(); | ||
| + } | ||
| + | ||
| + public int lastRepeat() | ||
| + { | ||
| + return ((Integer)repeats.lastElement()).intValue(); | ||
| + } | ||
| + | ||
| + public int numRepeats() | ||
| + { | ||
| + return repeats.size(); | ||
| + } | ||
| + | ||
| + public int numSpacers() | ||
| + { | ||
| + return numRepeats() - 1; | ||
| + } | ||
| + | ||
| + public String repeatStringAt(int i) | ||
| + { | ||
| + int currRepeatStartIndex = ((Integer)repeats.elementAt(i)).intValue(); | ||
| + int currRepeatEndIndex = currRepeatStartIndex + repeatLength - 1; | ||
| + return DNASequence.seq.substring(currRepeatStartIndex, currRepeatEndIndex + 1); | ||
| + } | ||
| + | ||
| + public String spacerStringAt(int i) | ||
| + { | ||
| + int currRepeatEndIndex = ((Integer)repeats.elementAt(i)).intValue() + repeatLength - 1; | ||
| + int nextRepeatStartIndex = ((Integer)repeats.elementAt(i + 1)).intValue(); | ||
| + int currSpacerStartIndex = currRepeatEndIndex + 1; | ||
| + int currSpacerEndIndex = nextRepeatStartIndex - 1; | ||
| + | ||
| + return DNASequence.seq.substring(currSpacerStartIndex, currSpacerEndIndex + 1); | ||
| + } | ||
| + | ||
| + public int averageSpacerLength() | ||
| + { | ||
| + int sum = 0; | ||
| + for (int i = 0; i < numSpacers(); i++) | ||
| + { | ||
| + sum = sum + spacerStringAt(i).length(); | ||
| + } | ||
| + return sum/numSpacers(); | ||
| + } | ||
| + | ||
| + public int averageRepeatLength() | ||
| + { | ||
| + int sum = 0; | ||
| + for (int i = 0; i < numRepeats(); i++) | ||
| + { | ||
| + sum = sum + repeatStringAt(i).length(); | ||
| + } | ||
| + return sum/numRepeats(); | ||
| + } | ||
| + | ||
| + public String toString() | ||
| + { | ||
| + String str = ""; | ||
| + | ||
| + String repeat, spacer, prevSpacer; | ||
| + repeat = spacer = prevSpacer = ""; | ||
| + | ||
| + str += "POSITION\tREPEAT\t\t\t\tSPACER\n"; | ||
| + | ||
| + str +="--------\t"; | ||
| + | ||
| + for (int y = 0; y < this.repeatLength(); y++) | ||
| + str +="-"; | ||
| + str +="\t"; | ||
| + | ||
| + for (int z = 0; z < this.averageSpacerLength(); z++) | ||
| + str += "-"; | ||
| + str +="\n"; | ||
| + | ||
| + | ||
| + //add 1 to each position, to offset programming languagues that begin at 0 rather than 1 | ||
| + for (int m = 0; m < numRepeats(); m++) | ||
| + { | ||
| + //repeat = getRepeat(m); | ||
| + str += (repeatAt(m) + 1) + "\t\t" + repeatStringAt(m) + "\t"; | ||
| + | ||
| + // print spacer | ||
| + // because there are no spacers after the last repeat, we stop early (m < crisprIndexVector.size() - 1) | ||
| + if (m < numSpacers()) | ||
| + { | ||
| + prevSpacer = spacer; | ||
| + spacer = spacerStringAt(m); | ||
| + str += spacer; | ||
| + | ||
| + str +="\t[ " + repeatStringAt(m).length() + ", " + spacerStringAt(m).length() + " ]"; | ||
| + //str +="--[" + DNASequence.getSimilarity(repeatStringAt(m), spacerStringAt(m)) + "]"; | ||
| + //str +="--[" + DNASequence.getSimilarity(spacer, prevSpacer) + "]"; | ||
| + str += "\n"; | ||
| + } | ||
| + } | ||
| + | ||
| + | ||
| + str +="\n--------\t"; | ||
| + | ||
| + for (int x = 0; x < this.repeatLength(); x++) | ||
| + str += "-"; | ||
| + str +="\t"; | ||
| + | ||
| + for (int z = 0; z < this.averageSpacerLength(); z++) | ||
| + str += "-"; | ||
| + str +="\n"; | ||
| + | ||
| + return str; | ||
| + } | ||
| + | ||
| +} | ||
| + |
Oops, something went wrong.
0 comments on commit
26d6dfc