-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
namespace byte2dnk | ||
{ | ||
using System; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using Algorithm; | ||
using Pastel; | ||
using static Log; | ||
internal static class Host | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
//if(!args.Any()) | ||
// Error($"No file specified.", 1); | ||
StringToCodons(); | ||
} | ||
|
||
|
||
public static void StringToCodons() | ||
{ | ||
var str = "Влад Гей"; | ||
|
||
Console.OutputEncoding = Encoding.Unicode; | ||
|
||
Info($"String: '{str.Pastel(Color.Gray)}', Length: {str.Length}"); | ||
var asw = HexCodon.Encode(Encoding.UTF8.GetBytes(str)).Select(x => | ||
$"{x.Acid.Symbol.ToString().Pastel(getColorByAminoAcidsState(x.Acid.State))}"); | ||
Info($"acid map: {string.Join(" ", asw)}"); | ||
Info($""); | ||
Info($"Detail table:"); | ||
|
||
foreach (var codon in HexCodon.Encode(Encoding.UTF8.GetBytes(str))) | ||
Info($"\t{codon.Value.Pastel(getColorByAminoAcidsState(codon.Acid.State))} {codon.Acid.FullName}/{codon.Acid.Symbol}"); | ||
Console.WriteLine(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
namespace byte2dnk | ||
{ | ||
using System; | ||
using System.Drawing; | ||
using System.Molecular.Acid; | ||
using Pastel; | ||
using static System.Console; | ||
|
||
internal static class Log | ||
{ | ||
public static void Error(string msg, int? exitCode) | ||
{ | ||
WriteLine($"[{"b2d".Pastel(Color.Coral)}][{"ERR".Pastel(Color.Red)}]: {msg}"); | ||
if(exitCode is null) | ||
return; | ||
Environment.Exit(exitCode.Value); | ||
} | ||
public static void Warn(string msg) | ||
{ | ||
WriteLine($"[{"b2d".Pastel(Color.Coral)}][{"WRN".Pastel(Color.Orange)}]: {msg}"); | ||
} | ||
public static void Info(string msg) | ||
{ | ||
WriteLine($"[{"b2d".Pastel(Color.Coral)}]: {msg}"); | ||
} | ||
|
||
public static Color getColorByAminoAcidsState(AAS state) => | ||
state switch | ||
{ | ||
AAS.Acidic => Color.MediumPurple, | ||
AAS.Basic => Color.CornflowerBlue, | ||
AAS.NonPolar => Color.Yellow, | ||
AAS.Polar => Color.MediumSeaGreen, | ||
AAS.Terminator => Color.DarkRed, | ||
_ => Color.White, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Pastel" Version="1.3.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\System.Molecular\System.Molecular.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |