本文整理汇总了C#中IMatrixData.AddStringColumn方法的典型用法代码示例。如果您正苦于以下问题:C# IMatrixData.AddStringColumn方法的具体用法?C# IMatrixData.AddStringColumn怎么用?C# IMatrixData.AddStringColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMatrixData
的用法示例。
在下文中一共展示了IMatrixData.AddStringColumn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
int stringColumnIndx = param.GetParam<int>("Sequence window").Value;
string[] win = mdata.StringColumns[stringColumnIndx];
int start = param.GetParam<int>("Start").Value - 1;
int length = param.GetParam<int>("Length").Value;
if (start < 0){
processInfo.ErrString = "Start position cannot be smaller than 1.";
return;
}
if (start + length > win[0].Length){
processInfo.ErrString = "Start + length cannot exceed the total length of the sequence.";
return;
}
string[] shortenedMotifs = new string[win.Length];
for (int i = 0; i < mdata.RowCount; ++i){
shortenedMotifs[i] = win[i].Substring(start, length);
}
mdata.AddStringColumn("Short sequence window", "", shortenedMotifs);
}
示例2: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
string[] seqWins;
string[] subAccs;
string[] kinases;
string[] kinAccs;
string[] species;
PhosphoSitePlusParser.ParseKinaseSubstrate(out seqWins, out subAccs, out kinases, out kinAccs, out species);
if (seqWins == null){
processInfo.ErrString = "File does not exist.";
return;
}
string[] up = mdata.StringColumns[param.GetParam<int>("Uniprot column").Value];
string[][] uprot = new string[up.Length][];
for (int i = 0; i < up.Length; i++){
uprot[i] = up[i].Length > 0 ? up[i].Split(';') : new string[0];
}
string[] win = mdata.StringColumns[param.GetParam<int>("Sequence window").Value];
Dictionary<string, List<Tuple<string, string, string>>> substrateProperties =
new Dictionary<string, List<Tuple<string, string, string>>>();
for (int i = 0; i < seqWins.Length; i++){
string subAcc = subAccs[i];
if (!substrateProperties.ContainsKey(subAcc)){
substrateProperties.Add(subAcc, new List<Tuple<string, string, string>>());
}
substrateProperties[subAcc].Add(new Tuple<string, string, string>(seqWins[i], kinases[i], kinAccs[i]));
}
string[] kinaseNameColumn = new string[uprot.Length];
string[] kinaseUniprotColumn = new string[uprot.Length];
for (int i = 0; i < kinaseNameColumn.Length; i++){
string[] win1 = AddKnownSites.TransformIl(win[i]).Split(';');
HashSet<string> kinaseNamesHits = new HashSet<string>();
HashSet<string> kinaseUniprotHits = new HashSet<string>();
foreach (string ux in uprot[i]){
if (substrateProperties.ContainsKey(ux)){
List<Tuple<string, string, string>> properties = substrateProperties[ux];
foreach (Tuple<string, string, string> property in properties){
string w = property.Item1;
if (AddKnownSites.Contains(win1, AddKnownSites.TransformIl(w.ToUpper().Substring(1, w.Length - 2)))){
kinaseNamesHits.Add(property.Item2);
kinaseUniprotHits.Add(property.Item3);
}
}
}
}
kinaseNameColumn[i] = kinaseNamesHits.Count > 0 ? StringUtils.Concat(";", ArrayUtils.ToArray(kinaseNamesHits)) : "";
kinaseUniprotColumn[i] = kinaseUniprotHits.Count > 0
? StringUtils.Concat(";", ArrayUtils.ToArray(kinaseUniprotHits))
: "";
}
mdata.AddStringColumn("PhosphoSitePlus kinase", "", kinaseNameColumn);
mdata.AddStringColumn("PhosphoSitePlus kinase uniprot", "", kinaseUniprotColumn);
}
示例3: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
string mod = param.GetParam<int>("Modification").StringValue;
string[] seqWins;
string[] accs;
string[] pubmedLtp;
string[] pubmedMs2;
string[] cstMs2;
string[] species;
PhosphoSitePlusParser.ParseKnownMod(mod, out seqWins, out accs, out pubmedLtp, out pubmedMs2, out cstMs2, out species);
if (seqWins == null){
processInfo.ErrString = "File does not exist.";
return;
}
string[] up = mdata.StringColumns[param.GetParam<int>("Uniprot column").Value];
string[][] uprot = new string[up.Length][];
for (int i = 0; i < up.Length; i++){
uprot[i] = up[i].Length > 0 ? up[i].Split(';') : new string[0];
}
string[] win = mdata.StringColumns[param.GetParam<int>("Sequence window").Value];
Dictionary<string, List<int>> map = new Dictionary<string, List<int>>();
for (int i = 0; i < seqWins.Length; i++){
string acc = accs[i];
if (!map.ContainsKey(acc)){
map.Add(acc, new List<int>());
}
map[acc].Add(i);
}
string[] newCol = new string[uprot.Length];
string[][] newCatCol = new string[uprot.Length][];
string[][] originCol = new string[uprot.Length][];
for (int i = 0; i < newCol.Length; i++){
string[] win1 = TransformIl(win[i]).Split(';');
HashSet<string> wins = new HashSet<string>();
HashSet<string> origins = new HashSet<string>();
foreach (string ux in uprot[i]){
if (map.ContainsKey(ux)){
List<int> n = map[ux];
foreach (int ind in n){
string s = seqWins[ind];
if (Contains(win1, TransformIl(s.ToUpper().Substring(1, s.Length - 2)))){
wins.Add(s);
if (pubmedLtp[ind].Length > 0){
origins.Add("LTP");
}
if (pubmedMs2[ind].Length > 0){
origins.Add("HTP");
}
if (cstMs2[ind].Length > 0){
origins.Add("CST");
}
}
}
}
}
if (wins.Count > 0){
newCol[i] = StringUtils.Concat(";", ArrayUtils.ToArray(wins));
newCatCol[i] = new[]{"+"};
string[] x = ArrayUtils.ToArray(origins);
Array.Sort(x);
originCol[i] = x;
} else{
newCol[i] = "";
newCatCol[i] = new string[0];
originCol[i] = new string[0];
}
}
mdata.AddStringColumn("PhosphoSitePlus window", "", newCol);
mdata.AddCategoryColumn("Known site", "", newCatCol);
mdata.AddCategoryColumn("Origin", "", originCol);
}
示例4: ProcessData
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
ref IDocumentData[] documents, ProcessInfo processInfo)
{
int proteinIdColumnInd = param.GetParam<int>("Protein IDs").Value;
string[][] proteinIds = new string[mdata.RowCount][];
string[][] leadingIds = new string[mdata.RowCount][];
List<string> allIds = new List<string>();
for (int row = 0; row < mdata.RowCount; row++){
proteinIds[row] = mdata.StringColumns[proteinIdColumnInd][row].Split(';');
leadingIds[row] = new[]{proteinIds[row][0]};
allIds.AddRange(proteinIds[row]);
}
string fastaFilePath = param.GetParam<string>("Fasta file").Value;
Fasta fasta = new Fasta();
fasta.ParseFile(fastaFilePath, processInfo);
// Text annotations
processInfo.Status("Adding fasta header annotations.");
int[] selection =
param.GetParamWithSubParams<int>("Fasta header annotations").GetSubParameters().GetParam<int[]>("Annotations").Value;
string[][] idsToBeAnnotated = (param.GetParamWithSubParams<int>("Fasta header annotations").Value == 0)
? proteinIds
: leadingIds;
ProteinSequence[][] fastaEntries = new ProteinSequence[mdata.RowCount][];
for (int row = 0; row < mdata.RowCount; row++){
List<ProteinSequence> rowEntries = new List<ProteinSequence>();
foreach (string id in idsToBeAnnotated[row]){
ProteinSequence entry = fasta.GetEntry(id);
if (entry == null){
continue;
}
rowEntries.Add(entry);
}
fastaEntries[row] = rowEntries.ToArray();
}
if (ArrayUtils.Contains(selection, 0)){ // Entry name
string[] annotationColumn = new string[mdata.RowCount];
for (int row = 0; row < mdata.RowCount; row++){
List<string> rowAnnotations = new List<string>();
foreach (ProteinSequence entry in fastaEntries[row]){
string entryName = entry.EntryName;
if (entryName != null && !ArrayUtils.Contains(rowAnnotations, entryName)){
rowAnnotations.Add(entryName);
}
}
annotationColumn[row] = string.Join(";", rowAnnotations.ToArray());
}
mdata.AddStringColumn("Entry name", "", annotationColumn);
}
if (ArrayUtils.Contains(selection, 1)){ // Gene name
string[] annotationColumn = new string[mdata.RowCount];
for (int row = 0; row < mdata.RowCount; row++){
List<string> rowAnnotations = new List<string>();
foreach (ProteinSequence entry in fastaEntries[row]){
string geneName = entry.GeneName;
if (geneName != null && !ArrayUtils.Contains(rowAnnotations, geneName)){
rowAnnotations.Add(geneName);
}
}
annotationColumn[row] = string.Join(";", rowAnnotations.ToArray());
}
mdata.AddStringColumn("Gene name", "", annotationColumn);
}
if (ArrayUtils.Contains(selection, 2)){
// Verbose protein name, i.e. all protein names annotated in all fasta headers, including the
//'Isoform x of...' prefixes and '(Fragment)' suffixes
string[] annotationColumn = new string[mdata.RowCount];
for (int row = 0; row < mdata.RowCount; row++){
List<string> rowAnnotations = new List<string>();
foreach (ProteinSequence entry in fastaEntries[row]){
string proteinName = entry.ProteinName;
if (proteinName != null && !ArrayUtils.Contains(rowAnnotations, proteinName)){
rowAnnotations.Add(proteinName);
}
}
annotationColumn[row] = string.Join(";", rowAnnotations.ToArray());
}
mdata.AddStringColumn("Protein name (verbose)", "", annotationColumn);
}
if (ArrayUtils.Contains(selection, 3)){ // Consensus protein name
string[] annotationColumn = new string[mdata.RowCount];
for (int row = 0; row < mdata.RowCount; row++){
List<string> rowAnnotations = new List<string>();
foreach (ProteinSequence entry in fastaEntries[row]){
string proteinName = entry.ConsensusProteinName;
if (proteinName != null && !ArrayUtils.Contains(rowAnnotations, proteinName)){
rowAnnotations.Add(proteinName);
}
}
annotationColumn[row] = String.Join(";", rowAnnotations.ToArray());
}
mdata.AddStringColumn("Protein name", "", annotationColumn);
}
if (ArrayUtils.Contains(selection, 4)){ // Species
string[] annotationColumn = new string[mdata.RowCount];
for (int row = 0; row < mdata.RowCount; row++){
List<string> rowAnnotations = new List<string>();
foreach (ProteinSequence entry in fastaEntries[row]){
string speciesName = entry.Species;
if (speciesName != null && !ArrayUtils.Contains(rowAnnotations, speciesName)){
rowAnnotations.Add(speciesName);
//.........这里部分代码省略.........