//--------------------------------------------------------------------------------
// File: Utilities.cs
// Author: Timothy O'Connor
// © Copyright University of Queensland, 2012-2014. All rights reserved.
// License:
//--------------------------------------------------------------------------------
namespace Tools
{
using System.Collections.Generic;
using System.IO;
using System.Linq;
///
/// Static data processing methods
///
public static class Utilities
{
///
/// Paste together cell type and expression type used for generating a map or regression score
///
/// The source.
/// Cell line.
/// Expression type.
public static string ScoreSource(string tissue, string expressionType)
{
return tissue + "." + expressionType;
}
///
/// TFs the score source.
///
/// The score source.
/// Tf name.
/// Cell line.
/// Expression type.
public static string TFScoreSource(string tfName, string tissue, string expressionType)
{
return string.Join(".", new List { tfName, tissue, expressionType });
}
///
/// Gets the name of the drm score file.
///
/// The drm score file name.
/// Source file name.
/// the score source type.
public static string GetLocicoreFileName(string sourceFileName, string scoreSource)
{
return GetScoreFileName("Locicores." + scoreSource, sourceFileName.Split('/').Last().Replace(".", "_"));
}
///
/// Gets the name of the tss score file.
///
/// The tss score file name.
/// Source file name.
/// the score source type.
public static string GetTssScoreFileName(string sourceFileName, string scoreSource)
{
return GetScoreFileName("TssScores." + scoreSource, sourceFileName.Split('/').Last().Replace(".", "_"));
}
///
/// Gets the name of the score file.
///
/// The score file name.
/// Score type.
/// Source file name.
public static string GetScoreFileName(string scoreType, string sourceFileName)
{
return string.Format("../temp/GenomicFeatures/{0}.{1}.tsv", scoreType, sourceFileName);
}
///
/// Gets the ChIP data file names.
///
/// The ch IP data file names.
/// Chip file name.
public static IEnumerable GetChIPDataFileNames(string chipFileName)
{
using (TextReader tr = new StreamReader(chipFileName))
{
return tr.ReadToEnd()
.Split('\n')
.Where(line => !string.IsNullOrWhiteSpace(line))
.Select(line => line.Trim());
}
}
///
/// Gets the ChIP data set names.
///
/// The ch IP data set names.
/// Chip file name.
public static IEnumerable GetChIPDataSetNames(string chipFileName)
{
return GetChIPDataFileNames(chipFileName).Select(x => Path.GetFileNameWithoutExtension(x).Split('/').Last().Replace(".", "_"));
}
}
}