package jgi; import java.util.Arrays; import dna.AminoAcid; import fileIO.ByteFile; import fileIO.FileFormat; import shared.Tools; import structures.IntList; public class Assembly { public Assembly(String fname_) { fname=fname_; load(); } void load() { FileFormat ff=FileFormat.testInput(fname, FileFormat.FASTA, null, true, true); assert(ff.fasta()); ByteFile bf=ByteFile.makeByteFile(ff); clear(); acgtnio=new long[7]; int contigLen=0; for(byte[] line=bf.nextLine(); line!=null; line=bf.nextLine()) { if(line[0]=='>') { headerLength+=(line.length-1); if(firstHeader==null && line.length>1) { firstHeader=new String(line, 1, line.length-1); } if(contigLen>0) { contigs.add(contigLen); } contigLen=0; }else { addToACGTNIO(line); contigLen+=line.length; } } bf.close(); contigs.sort(); contigs.reverse(); length=contigs.sumLong(); } void addToACGTNIO(byte[] line) { for(byte b : line) { byte x=baseToACGTNIO[b]; acgtnio[x]++; } } void clear() { contigs.clear(); length=0; headerLength=0; firstHeader=null; acgtnio=null; } float gc() { float AT=acgtnio[A]+acgtnio[T]+acgtnio[U]; float GC=acgtnio[G]+acgtnio[C]; return GC/Tools.max(1, AT+GC); } long lengthAtLeast(int minimum) { long sum=0; for(int i=0; i=0 && array[i]==OTHER) { array[i]=IUPAC; } } return array; } }