public static string GetFormattedSequence(Sequence sequence, SequenceFormat sequenceFormat, string mergeMaster = null) { return(GetFormattedSequence(new List <Sequence>() { sequence }, sequenceFormat, mergeMaster)); }
public void WellknownInterfaces() { var baseObject = new SequenceFormat() { ArrayFormat = new[] { new MyStructFixed(1, 10, 3.4f), new MyStructFixed(2, 6, 5.2f) }, CollectionFormat = new List <int> { 1, 10, 100 }, DictionaryFormat = new Dictionary <int, int> { { 1, 100 }, { -4, 9999 } }, InterafceDictionaryFormat = new Dictionary <int, int> { { 1, 100 }, { -4, 9999 } }, InterfaceCollectionFormat = new[] { 1, 10, 1000 }, InterfaceEnumerableFormat = new[] { 1, 2, 3 }, ReadOnlyCollectionFormat = new System.Collections.ObjectModel.ReadOnlyCollection <int>(new[] { 1, 10, 100 }), LookupFormat = Enumerable.Range(1, 5).ToLookup(x => x % 2 == 0), #if !UNITY InterfaceSetFormat = new HashSet <int>(new[] { 1, 9099, 3452 }), InterfaceReadOnlyCollectionFormat = new[] { 5, 6, 7 }, ReadOnlyDictionaryFormat = new System.Collections.ObjectModel.ReadOnlyDictionary <int, int>(new Dictionary <int, int> { { 9, 9999 } }), InterfaceReadOnlyDictionaryFormat = new System.Collections.ObjectModel.ReadOnlyDictionary <int, int>(new Dictionary <int, int> { { 9, 9999 } }), #endif }; var converted = ZeroFormatterSerializer.Convert(baseObject, true); converted.ArrayFormat[0].MyProperty1.Is(1); converted.ArrayFormat[0].MyProperty2.Is(10); converted.ArrayFormat[0].MyProperty3.Is(3.4f); converted.ArrayFormat[1].MyProperty1.Is(2); converted.ArrayFormat[1].MyProperty2.Is(6); converted.ArrayFormat[1].MyProperty3.Is(5.2f); converted.CollectionFormat.Is(1, 10, 100); converted.DictionaryFormat[1].Is(100); converted.DictionaryFormat[-4].Is(9999); converted.InterafceDictionaryFormat[1].Is(100); converted.InterafceDictionaryFormat[-4].Is(9999); converted.InterfaceCollectionFormat.Is(1, 10, 1000); converted.InterfaceEnumerableFormat.Is(1, 2, 3); converted.ReadOnlyCollectionFormat.Is(1, 10, 100); converted.LookupFormat[true].Is(2, 4); converted.LookupFormat[false].Is(1, 3, 5); #if !UNITY converted.InterfaceSetFormat.OrderBy(x => x).Is(1, 3452, 9099); converted.InterfaceReadOnlyCollectionFormat.Is(1, 10, 100); converted.ReadOnlyDictionaryFormat[9].Is(9999); converted.InterfaceReadOnlyDictionaryFormat[9].Is(9999); #endif }
public static string GetFormattedSequence(List <Sequence> sequenceList, SequenceFormat sequenceFormat, string mergeMaster = null) { var result = new List <string>(); if (sequenceFormat == SequenceFormat.Pir) { if (!String.IsNullOrWhiteSpace(mergeMaster)) { var id = sequenceList.FirstOrDefault(a => a.Id == mergeMaster); //result.Add(id.Item1.Replace(":", "_").Insert(1, "P1;")); //result.Add("sequence:" + id.Item1.Replace(">", "").Replace(":", "_") + "::::::::"); result.Add(">P1;query"); result.Add("sequence:query::::::::"); } } for (int index = 0; index < sequenceList.Count; index++) { var id = sequenceList[index]; if (sequenceFormat == SequenceFormat.Fasta) { result.Add(id.Id); } else if (sequenceFormat == SequenceFormat.Pir) { if (String.IsNullOrWhiteSpace(mergeMaster)) { //result.Add(id.Item1.Replace(":", "_").Insert(1, "P1;")); //result.Add("sequence:" + id.Item1.Replace(">", "").Replace(":", "_") + "::::::::"); result.Add(">P1;query"); result.Add("sequence:query::::::::"); } } var s = id.FullSequence; while (s.Length > 80) { result.Add(s.Substring(0, 80)); s = s.Remove(0, 80); } if (s.Length > 0) { result.Add(s); } if (sequenceFormat == SequenceFormat.Pir) { if (String.IsNullOrWhiteSpace(mergeMaster) || index == sequenceList.Count - 1) { result[result.Count - 1] = result[result.Count - 1] + "*"; } else { result[result.Count - 1] = result[result.Count - 1] + "/"; } } } return(string.Join(Environment.NewLine, result) + Environment.NewLine); }