Skip to content

Commit

Permalink
working revcomp with Dart M4
Browse files Browse the repository at this point in the history
  • Loading branch information
jwendel committed Apr 17, 2013
1 parent 8d42113 commit fd73fb1
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions revcomp/revcomp.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import 'dart:io';
import 'dart:typeddata';

void main() {
String src = "CGATMKRYVBHD";
String dst = "GCTAKMYRBVDH";
Uint8List tbl = new Uint8List(256);

final String src = "CGATMKRYVBHD";
final String dst = "GCTAKMYRBVDH";
final Uint8List tbl = new Uint8List(256);

const int LINE_LENGTH = 60;
final Uint8List buffer = new Uint8List(LINE_LENGTH);
const int BUFFER_SIZE = 1024*1024;


void main() {
// Set up lookup table
for (int i = 0; i < tbl.length; i++)
tbl[i] = i;
Expand All @@ -15,8 +21,6 @@ void main() {
tbl[src.toLowerCase().codeUnitAt(i)] = dst.codeUnitAt(i);
}

const int BUFFER_SIZE = 1024*1024;
Uint8List buffer = new Uint8List(60);
List<int> list = new List<int>();
bool commentLine = false;
Uint8List sbuf = new Uint8List(BUFFER_SIZE);
Expand All @@ -30,7 +34,7 @@ void main() {
while (pos < BUFFER_SIZE) {
sbuf[pos++] = src[start++];
}
stdout.writeBytes(sbuf);
stdout.add(sbuf);
sbuf = new Uint8List(BUFFER_SIZE);
pos = 0;
}
Expand All @@ -42,7 +46,7 @@ void main() {

void addNewline() {
if (pos == BUFFER_SIZE) {
stdout.writeBytes(sbuf);
stdout.add(sbuf);
sbuf = new Uint8List(BUFFER_SIZE);
pos = 0;
}
Expand All @@ -60,7 +64,7 @@ void main() {

// Print the reverse components for the last block
for (int g in list.reversed) {
if (count == 60) {
if (count == LINE_LENGTH) {

copyAndPrint(buffer, count);
addNewline();
Expand Down Expand Up @@ -100,7 +104,7 @@ void main() {
} else {
int count = 0;
for (int data in list.reversed) {
if (count == 60) {
if (count == LINE_LENGTH) {
copyAndPrint(buffer, count);
addNewline();
count=0;
Expand All @@ -113,6 +117,6 @@ void main() {
}
}
if (pos > 0)
stdout.writeBytes(sbuf.sublist(0, pos));
stdout.add(sbuf.sublist(0, pos));
});
}

0 comments on commit fd73fb1

Please sign in to comment.