-
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.
Added collate sub-command implementation and refactored the program.
- Loading branch information
Maozi Chen
committed
Sep 25, 2020
1 parent
b17d343
commit 4d1bff1
Showing
45 changed files
with
2,628 additions
and
119 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,15 @@ | ||
using System; | ||
|
||
namespace mccsx | ||
{ | ||
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)] | ||
internal sealed class AminoAcidNamesAttribute : Attribute | ||
{ | ||
public AminoAcidNamesAttribute(string shortName, char code) | ||
=> (ShortName, Code) = (shortName, code); | ||
|
||
public string ShortName { get; } | ||
|
||
public char Code { get; } | ||
} | ||
} |
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,13 @@ | ||
using System; | ||
|
||
namespace mccsx | ||
{ | ||
[AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = false)] | ||
internal sealed class LinkageImplAttribute : Attribute | ||
{ | ||
public LinkageImplAttribute(Type linkageClass) | ||
=> LinkageClass = linkageClass; | ||
|
||
public Type LinkageClass { get; } | ||
} | ||
} |
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,51 @@ | ||
namespace mccsx | ||
{ | ||
public enum AminoAcid | ||
{ | ||
// Charged (side chains often make salt bridges) | ||
[AminoAcidNames("Arg", 'R')] | ||
Arginine, | ||
[AminoAcidNames("Lys", 'K')] | ||
Lysine, | ||
[AminoAcidNames("Asp", 'D')] | ||
AsparticAcid, | ||
[AminoAcidNames("Glu", 'E')] | ||
GlutamicAcid, | ||
|
||
// Polar (usually participate in hydrogen bonds as proton donors or acceptors) | ||
[AminoAcidNames("Gln", 'Q')] | ||
Glutamine, | ||
[AminoAcidNames("Asn", 'N')] | ||
Asparagine, | ||
[AminoAcidNames("His", 'H')] | ||
Histidine, | ||
[AminoAcidNames("Ser", 'S')] | ||
Serine, | ||
[AminoAcidNames("Thr", 'T')] | ||
Threonine, | ||
[AminoAcidNames("Tyr", 'Y')] | ||
Tyrosine, | ||
[AminoAcidNames("Cys", 'C')] | ||
Cysteine, | ||
[AminoAcidNames("Trp", 'W')] | ||
Tryptophan, | ||
|
||
// Hydrophobic (normally buried inside the protein core) | ||
[AminoAcidNames("Ala", 'A')] | ||
Alanine, | ||
[AminoAcidNames("Ile", 'I')] | ||
Isoleucine, | ||
[AminoAcidNames("Leu", 'L')] | ||
Leucine, | ||
[AminoAcidNames("Met", 'M')] | ||
Methionine, | ||
[AminoAcidNames("Phe", 'F')] | ||
Phenylalanine, | ||
[AminoAcidNames("Val", 'V')] | ||
Valine, | ||
[AminoAcidNames("Pro", 'P')] | ||
Proline, | ||
[AminoAcidNames("Gly", 'G')] | ||
Glycine, | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
namespace mccsx | ||
using mccsx.Statistics; | ||
|
||
namespace mccsx | ||
{ | ||
internal enum Linkage | ||
{ | ||
[LinkageImpl(typeof(FarthestPointMethod))] | ||
farthest, | ||
|
||
[LinkageImpl(typeof(NearestPointMethod))] | ||
nearest, | ||
|
||
[LinkageImpl(typeof(AverageDistanceMethod))] | ||
average, | ||
} | ||
} |
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,20 @@ | ||
using System; | ||
using System.Runtime.Serialization; | ||
|
||
namespace mccsx | ||
{ | ||
[Serializable] | ||
public class FilterColumnException : Exception | ||
{ | ||
public FilterColumnException() { } | ||
public FilterColumnException(string message) : base(message) { } | ||
public FilterColumnException(string message, Exception inner) : base(message, inner) { } | ||
public FilterColumnException(string message, string filterName) : base(message) => FilterName = filterName; | ||
public FilterColumnException(string message, string filterName, Exception inner) : base(message, inner) => FilterName = filterName; | ||
protected FilterColumnException( | ||
SerializationInfo info, | ||
StreamingContext context) : base(info, context) { } | ||
|
||
public string? FilterName { get; } | ||
} | ||
} |
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,20 @@ | ||
using System; | ||
using System.Runtime.Serialization; | ||
|
||
namespace mccsx | ||
{ | ||
[Serializable] | ||
public class RawRecvDataFormatException : Exception | ||
{ | ||
public RawRecvDataFormatException() { } | ||
public RawRecvDataFormatException(string message) : base(message) { } | ||
public RawRecvDataFormatException(string message, Exception inner) : base(message, inner) { } | ||
public RawRecvDataFormatException(string message, string fileName) : base(message) => FileName = fileName; | ||
public RawRecvDataFormatException(string message, string fileName, Exception inner) : base(message, inner) => FileName = fileName; | ||
protected RawRecvDataFormatException( | ||
SerializationInfo info, | ||
StreamingContext context) : base(info, context) { } | ||
|
||
public string? FileName { get; } | ||
} | ||
} |
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,63 @@ | ||
using mccsx.Helpers; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace mccsx.Extensions | ||
{ | ||
internal static class AminoAcidExtensions | ||
{ | ||
private static readonly IDictionary<string, AminoAcid> NameDict = EnumAnnotationHelper<AminoAcid> | ||
.Enums | ||
.ToDictionary(o => EnumAnnotationHelper<AminoAcid>.GetAttribute<AminoAcidNamesAttribute>(o).ShortName.ToUpper()); | ||
|
||
public static AminoAcid ParseAminoAcid(this string s) | ||
{ | ||
if (s.Length != 3) | ||
throw new InvalidCastException(); | ||
s = s.ToUpper(); | ||
if (!NameDict.ContainsKey(s)) | ||
throw new InvalidCastException(); | ||
return NameDict[s]; | ||
} | ||
|
||
public static bool TryParseAminoAcid(this string s, out AminoAcid value) | ||
{ | ||
return NameDict.TryGetValue(s.ToUpper(), out value); | ||
} | ||
|
||
public static int ParseResidueSequence(this string s) | ||
{ | ||
// Ala379 | ||
if (s.Length > 3 && char.IsLetter(s[2])) | ||
return int.Parse(s[3..]); | ||
// A379 | ||
if (s.Length > 1 && char.IsLetter(s[0])) | ||
return int.Parse(s[1..]); | ||
// 379 | ||
return int.Parse(s); | ||
} | ||
|
||
public static bool TryParseResidueSequence(this string s, out int resSeq) | ||
{ | ||
// Ala379 | ||
if (s.Length > 3 && char.IsLetter(s[2])) | ||
return int.TryParse(s[3..], out resSeq); | ||
// A379 | ||
if (s.Length > 1 && char.IsLetter(s[0])) | ||
return int.TryParse(s[1..], out resSeq); | ||
// 379 | ||
return int.TryParse(s, out resSeq); | ||
} | ||
|
||
public static string GetShortName(this AminoAcid value) | ||
{ | ||
return EnumAnnotationHelper<AminoAcid>.GetAttribute<AminoAcidNamesAttribute>(value).ShortName; | ||
} | ||
|
||
public static char GetCode(this AminoAcid value) | ||
{ | ||
return EnumAnnotationHelper<AminoAcid>.GetAttribute<AminoAcidNamesAttribute>(value).Code; | ||
} | ||
} | ||
} |
Oops, something went wrong.