Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,39 @@
|
|||
void printBaseCount(String string) throws IOException {
|
||||
BufferedReader reader = new BufferedReader(new StringReader(string));
|
||||
int index = 0;
|
||||
String sequence;
|
||||
int A = 0, C = 0, G = 0, T = 0;
|
||||
int a, c, g, t;
|
||||
while ((sequence = reader.readLine()) != null) {
|
||||
System.out.printf("%d %s ", index++, sequence);
|
||||
a = c = g = t = 0;
|
||||
for (char base : sequence.toCharArray()) {
|
||||
switch (base) {
|
||||
case 'A' -> {
|
||||
A++;
|
||||
a++;
|
||||
}
|
||||
case 'C' -> {
|
||||
C++;
|
||||
c++;
|
||||
}
|
||||
case 'G' -> {
|
||||
G++;
|
||||
g++;
|
||||
}
|
||||
case 'T' -> {
|
||||
T++;
|
||||
t++;
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.printf("[A %2d, C %2d, G %2d, T %2d]%n", a, c, g, t);
|
||||
}
|
||||
reader.close();
|
||||
int total = A + C + G + T;
|
||||
System.out.printf("%nTotal of %d bases%n", total);
|
||||
System.out.printf("A %3d (%.2f%%)%n", A, ((double) A / total) * 100);
|
||||
System.out.printf("C %3d (%.2f%%)%n", C, ((double) C / total) * 100);
|
||||
System.out.printf("G %3d (%.2f%%)%n", G, ((double) G / total) * 100);
|
||||
System.out.printf("T %3d (%.2f%%)%n", T, ((double) T / total) * 100);
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class orderedSequence {
|
||||
public static void main(String[] args) {
|
||||
Sequence gene = new Sequence("CGTAAAAAATTACAACGTCCTTTGGCTATCTCTTAAACTCCTGCTAAATGCTCGTGCTTTCCAATTATGTAAGCGTTCCGAGACGGGGTGGTCGATTCTGAGGACAAAGGTCAAGATGGAGCGCATCGAACGCAATAAGGATCATTTGATGGGACGTTTCGTCGACAAAGTCTTGTTTCGAGAGTAACGGCTACCGTCTTCGATTCTGCTTATAACACTATGTTCTTATGAAATGGATGTTCTGAGTTGGTCAGTCCCAATGTGCGGGGTTTCTTTTAGTACGTCGGGAGTGGTATTATATTTAATTTTTCTATATAGCGATCTGTATTTAAGCAATTCATTTAGGTTATCGCCGCGATGCTCGGTTCGGACCGCCAAGCATCTGGCTCCACTGCTAGTGTCCTAAATTTGAATGGCAAACACAAATAAGATTTAGCAATTCGTGTAGACGACCGGGGACTTGCATGATGGGAGCAGCTTTGTTAAACTACGAACGTAAT");
|
||||
gene.runSequence();
|
||||
}
|
||||
}
|
||||
|
||||
/** Separate class for defining behaviors */
|
||||
public class Sequence {
|
||||
|
||||
private final String seq;
|
||||
|
||||
public Sequence(String sq) {
|
||||
this.seq = sq;
|
||||
}
|
||||
|
||||
/** print the organized structure of the sequence */
|
||||
public void prettyPrint() {
|
||||
System.out.println("Sequence:");
|
||||
int i = 0;
|
||||
for ( ; i < seq.length() - 50 ; i += 50) {
|
||||
System.out.printf("%5s : %s\n", i + 50, seq.substring(i, i + 50));
|
||||
}
|
||||
System.out.printf("%5s : %s\n", seq.length(), seq.substring(i));
|
||||
}
|
||||
|
||||
/** display a base vs. frequency chart */
|
||||
public void displayCount() {
|
||||
Map<Character, Integer> counter = new HashMap<>();
|
||||
for (int i = 0 ; i < seq.length() ; ++i) {
|
||||
counter.merge(seq.charAt(i), 1, Integer::sum);
|
||||
}
|
||||
|
||||
System.out.println("Base vs. Count:");
|
||||
counter.forEach(
|
||||
key, value -> System.out.printf("%5s : %s\n", key, value));
|
||||
System.out.printf("%5s: %s\n", "SUM", seq.length());
|
||||
}
|
||||
|
||||
public void runSequence() {
|
||||
this.prettyPrint();
|
||||
this.displayCount();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue