package edu.toronto.bb.core.phred;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.biojava3.core.sequence.AccessionID;
import org.biojava3.core.sequence.template.Accessioned;

public class PhredScoreSequence implements Iterable<PhredScore>, Accessioned {

    private List<PhredScore> phredScores;
    private AccessionID accesionID;
    

    public PhredScoreSequence(String sequence) {		
        this.phredScores = parsePhredScoreList(sequence);
    }

    public PhredScore scoreAt(int index) {
        return phredScores.get(index);
    }	

    public List<PhredScore> getScores() {
        return phredScores;
    }

    public void setScoreAt(PhredScore score, int index) {
        phredScores.set(index, score);
    }

    public int length() {
        return phredScores.size();
    }

    private ArrayList<PhredScore> parsePhredScoreList(String sequence) {				
        ArrayList<PhredScore> listOfScores = new ArrayList<PhredScore>();

        if (sequence != null) {
            String[] rawScores= sequence.split("\\s+");
            for (String score : rawScores) {
                listOfScores.add(new PhredScore(Integer.parseInt(score)));
            }
        }

        return listOfScores;
    }
    
    public void setAccessionID(AccessionID id) {
        this.accesionID = id;
    }

    @Override
    public Iterator<PhredScore> iterator() {		
        return phredScores.iterator();
    }

    @Override
    public AccessionID getAccession() {
        return this.accesionID;
    }

}

@@ -84,16 +84,45 @@
 erator;%0A
+import java.util.LinkedList;%0A
 import j
@@ -333,16 +333,22 @@
 private 
+Linked
 List%3CPhr
@@ -788,32 +788,122 @@
 x, score);%0A    %7D
+%0A    %0A    public void pushScore(PhredScore score) %7B%0A        phredScores.push(score);%0A    %7D
 %0A%0A    public int
@@ -968,21 +968,22 @@
 private 
-Array
+Linked
 List%3CPhr
@@ -1042,21 +1042,22 @@
         
-Array
+Linked
 List%3CPhr
@@ -1084,21 +1084,22 @@
 s = new 
-Array
+Linked
 List%3CPhr

change to use LinkedList to keep track of scores