Skip to content

Commit

Permalink
modified the way to parse sequence file
Browse files Browse the repository at this point in the history
  • Loading branch information
wangqion committed Oct 21, 2014
1 parent 49de79d commit 4b0b584
Showing 1 changed file with 19 additions and 31 deletions.
50 changes: 19 additions & 31 deletions src/edu/msu/cme/rdp/alignment/AlignmentMerger.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,39 +96,27 @@ private static Map<File, char[]> getReferenceSeqs(List<File> alignmentFiles, Set
continue;
}

char[] refSeq = null;

System.err.println("Extracting reference from " + alignmentFile + " (format=" + format + ")");
char[] refSeq = null;

try {
if (format == SequenceFormat.FASTA) {
BufferedInputStream is = new BufferedInputStream(new FileInputStream(alignmentFile));
while(is.available() > 10000) {
is.skip(is.available() - 10000);
}

is.mark(1);
int c;
while((c = is.read()) != -1 && (char)c != '>') {
is.mark(1);
}
is.reset();

SeqReader reader = new SequenceReader(is);

Sequence seq;
while ((seq = reader.readNextSequence()) != null) {
if (seq.getSeqName().equals(refSeqId)) {
refSeq = seq.getSeqString().toCharArray();
break;
}
}
reader.close();
} else {
IndexedSeqReader reader = new IndexedSeqReader(alignmentFile);
refSeq = reader.readSeq(refSeqId).getSeqString().toCharArray();
reader.close();
}
if (format == SequenceFormat.FASTA) {
BufferedInputStream is = new BufferedInputStream(new FileInputStream(alignmentFile));

SeqReader reader = new SequenceReader(is);

Sequence seq;
while ((seq = reader.readNextSequence()) != null) {
if (seq.getSeqName().equals(refSeqId)) {
refSeq = seq.getSeqString().toCharArray();
break;
}
}
reader.close();
} else {
IndexedSeqReader reader = new IndexedSeqReader(alignmentFile);
refSeq = reader.readSeq(refSeqId).getSeqString().toCharArray();
reader.close();
}

if (refSeq == null) {
throw new IOException();
Expand Down

0 comments on commit 4b0b584

Please sign in to comment.