using UnityEngine; using System.Collections; using System.Collections.Generic; public class HankSequenceReader { public static List> ParseFrameSequence(string sequenceCsvFilePath) { List> data = CSVReader.Read (sequenceCsvFilePath); // debug purpose for(var i=0; i < data.Count; i++) { Debug.Log ("ft " + data[i]["ft"] + " " + "fs " + data[i]["fs"] + " " + "chip_seq " + data[i]["chip_seq"]); } return data; } public static int[] GetFrameSequence(float frequency, List> hankSeqData) { for(var i=0; i < hankSeqData.Count; i++) { if (float.Parse((string)hankSeqData [i] ["ft"]) == frequency) { Debug.Log ("Sequence for ft = " + frequency + " found!"); // parse the sequence string seq = (string)hankSeqData[i]["chip_seq"]; char[] seqArr = seq.ToCharArray(); int[] seqArrInt = new int[seqArr.Length]; for (int j = 0; j < seqArr.Length; j++) { seqArrInt [j] = int.Parse (seqArr [j] + ""); } return seqArrInt; } } Debug.Log ("Sequence for ft = " + frequency + " NOT FOUND!"); return new int[1]; } public static int GetFrameSequenceLength(float frequency, List> hankSeqData) { for(var i=0; i < hankSeqData.Count; i++) { if (float.Parse((string)hankSeqData [i] ["ft"]) == frequency) { Debug.Log ("Sequence length for ft = " + frequency + " found!"); // parse the sequence length string seq = (string)hankSeqData[i]["seq_length"]; return int.Parse (seq); } } Debug.Log ("Sequence length for ft = " + frequency + " NOT FOUND!"); return -1; } /** * Get the shortest sequence length (chip / frame sequence) from a list of frequencies */ public static int GetLongestSequenceLength(float[] frequencies, List> hankSeqData) { int _max = 0; int _currLen = 0; for (int i = 0; i < frequencies.Length; i++) { _currLen = GetFrameSequenceLength (frequencies [i], hankSeqData); if (_currLen > 0 &&_max < _currLen) _max = _currLen; } return _max; } }