Skip to content

Commit a6d7a4e

Browse files
authored
Merge pull request #61 from Genometric/dev
Merge dev on master for v.4.0.0 release.
2 parents 02ad59a + f467ad9 commit a6d7a4e

37 files changed

+571
-817
lines changed

GeUtilities.Tests/GeUtilities.Tests.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@
1616
<PackageLicenseUrl>https://github.com/Genometric/GeUtilities/blob/master/LICENSE</PackageLicenseUrl>
1717
<PackageProjectUrl>https://github.com/Genometric/GeUtilities</PackageProjectUrl>
1818
<RepositoryUrl>https://github.com/Genometric/GeUtilities</RepositoryUrl>
19-
<Version>2.0.0</Version>
19+
<Version>4.0.0</Version>
2020
<Description>Implements unit test functions for the GeUtilities.</Description>
21+
<PackageTags>genomics; genome analysis; building-blocks; parser; BED; VCF; GTF; RefSeq;</PackageTags>
22+
<PackageReleaseNotes>A major overhaul on the interfaces, functions signatures, and namespace naming. Namely:
23+
- Parsers constructors take least possible information, and all the other configuration could be set on an instace of the parser class.
24+
- By moving source file name from constructor to Parse function, now single instance of Parser can be used to parse multiple files.
25+
- A major overhaul of classes inheritance with the objective of making them more coherent.</PackageReleaseNotes>
2126
</PropertyGroup>
2227

2328
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

GeUtilities.Tests/IntervalParsers/BED/ColumnsOrder.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ public void ColumnsShuffle(byte chrColumn, byte leftColumn, sbyte rightColumn, b
3535
ValueColumn = valueColumn
3636
};
3737

38-
using (var testFile = new TempFileCreator(rg))
38+
using (var file = new TempFileCreator(rg))
3939
{
4040
// Act
4141
var parser = new BEDParser<ChIPSeqPeak>(
42-
testFile.TempFilePath,
4342
new BEDColumns()
4443
{
4544
Chr = chrColumn,
@@ -48,7 +47,7 @@ public void ColumnsShuffle(byte chrColumn, byte leftColumn, sbyte rightColumn, b
4847
Name = nameColumn,
4948
Value = valueColumn
5049
});
51-
var parsedPeak = parser.Parse().Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0];
50+
var parsedPeak = parser.Parse(file.Path).Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0];
5251

5352
// Assert
5453
Assert.True(parsedPeak.CompareTo(rg.Peak) == 0);
@@ -70,11 +69,11 @@ public void ColumnsSetters()
7069
StrandColumn = 0,
7170
};
7271

73-
using (var testFile = new TempFileCreator(rg))
72+
using (var file = new TempFileCreator(rg))
7473
{
7574
// Act
76-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath, rg.Columns);
77-
var parsedPeak = parser.Parse().Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0];
75+
var parser = new BEDParser<ChIPSeqPeak>(rg.Columns);
76+
var parsedPeak = parser.Parse(file.Path).Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0];
7877

7978
// Assert
8079
Assert.True(parsedPeak.CompareTo(rg.Peak) == 0);
@@ -95,11 +94,11 @@ public void TestSummit(sbyte summitColumn, int summit)
9594
var rg = new RegionGenerator { SummitColumn = summitColumn };
9695
rg.Summit = summit == -1 ? rg.Left + ((rg.Right - rg.Left) / 2) : summit;
9796

98-
using (var testFile = new TempFileCreator(rg))
97+
using (var file = new TempFileCreator(rg))
9998
{
10099
// Act
101-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath, rg.Columns);
102-
var parsedPeak = parser.Parse().Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0];
100+
var parser = new BEDParser<ChIPSeqPeak>(rg.Columns);
101+
var parsedPeak = parser.Parse(file.Path).Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0];
103102

104103
// Assert
105104
Assert.True(parsedPeak.Summit == rg.Summit);
@@ -122,13 +121,13 @@ public void TestStrand(sbyte strandColumn, char strand)
122121
StrandColumn = strandColumn
123122
};
124123

125-
using (var testFile = new TempFileCreator(rg))
124+
using (var file = new TempFileCreator(rg))
126125
{
127126
// Act
128-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath, rg.Columns);
127+
var parser = new BEDParser<ChIPSeqPeak>(rg.Columns);
129128

130129
// Assert
131-
Assert.True(parser.Parse().Chromosomes[rg.Chr].Strands.ContainsKey(strand));
130+
Assert.True(parser.Parse(file.Path).Chromosomes[rg.Chr].Strands.ContainsKey(strand));
132131
}
133132
}
134133

@@ -144,11 +143,11 @@ public void TestMultiStrand()
144143
"chr1\t50\t60\t#\tGeUtilities_02\t111.0", // Any strand name other than '+', '-', and '*' will be parsed as '*'.
145144
};
146145

147-
using (var testFile = new TempFileCreator(peaks))
146+
using (var file = new TempFileCreator(peaks))
148147
{
149148
// Act
150149
var parser = new BEDParser<ChIPSeqPeak>(
151-
testFile.TempFilePath, new BEDColumns
150+
new BEDColumns
152151
{
153152
Chr = 0,
154153
Left = 1,
@@ -158,7 +157,7 @@ public void TestMultiStrand()
158157
Value = 5
159158
});
160159

161-
var parsedData = parser.Parse();
160+
var parsedData = parser.Parse(file.Path);
162161

163162
// Assert
164163
Assert.True(parsedData.Chromosomes["chr1"].Strands.ContainsKey('*'));

GeUtilities.Tests/IntervalParsers/BED/ConcreteClassArguments.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ public void AllDefaultArguments()
1717
{
1818
// Arrange
1919
var rg = new RegionGenerator();
20-
using (var testFile = new TempFileCreator(rg))
20+
using (var file = new TempFileCreator(rg))
2121
{
2222
// Act
23-
var parser = new BEDParser(testFile.TempFilePath);
24-
var parsedPeak = parser.Parse().Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0];
23+
var parser = new BEDParser();
24+
var parsedPeak = parser.Parse(file.Path).Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0];
2525

2626
// Assert
2727
Assert.True(parsedPeak.CompareTo(rg.Peak) == 0);
@@ -33,11 +33,11 @@ public void FullySetArguments()
3333
{
3434
// Arrange
3535
var rg = new RegionGenerator();
36-
using (var testFile = new TempFileCreator(rg))
36+
using (var file = new TempFileCreator(rg))
3737
{
3838
// Act
39-
var parser = new BEDParser(testFile.TempFilePath, rg.Columns);
40-
var parsedPeak = parser.Parse().Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0];
39+
var parser = new BEDParser(rg.Columns);
40+
var parsedPeak = parser.Parse(file.Path).Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0];
4141

4242
// Assert
4343
Assert.True(parsedPeak.CompareTo(rg.Peak) == 0);

GeUtilities.Tests/IntervalParsers/BED/DefaultArguments.cs

Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ public void DefaultColumnsOrder()
1919
{
2020
// Arrange
2121
var rg = new RegionGenerator();
22-
using (var testFile = new TempFileCreator())
22+
using (var file = new TempFileCreator())
2323
{
2424
// Act
25-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath);
26-
var parsedPeak = parser.Parse().Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0];
25+
var parser = new BEDParser<ChIPSeqPeak>();
26+
var parsedPeak = parser.Parse(file.Path).Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0];
2727

2828
// Assert
2929
Assert.True(parsedPeak.CompareTo(rg.Peak) == 0);
@@ -39,14 +39,14 @@ public void DefaultColumnsOrder()
3939
public void AvoidHeader(int headerCount, byte readOffset)
4040
{
4141
// Arrange
42-
using (var testFile = new TempFileCreator(new RegionGenerator(), headerLineCount: headerCount))
42+
using (var file = new TempFileCreator(new RegionGenerator(), headerLineCount: headerCount))
4343
{
4444
// Act
45-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath)
45+
var parser = new BEDParser<ChIPSeqPeak>()
4646
{
4747
ReadOffset = readOffset
4848
};
49-
var parsedData = parser.Parse();
49+
var parsedData = parser.Parse(file.Path);
5050

5151
// Assert
5252
Assert.True(parsedData.Chromosomes.Count == 1);
@@ -63,11 +63,11 @@ public void AvoidHeader(int headerCount, byte readOffset)
6363
public void ReadChr(string chr)
6464
{
6565
// Arrange
66-
using (var testFile = new TempFileCreator(new RegionGenerator { Chr = chr }))
66+
using (var file = new TempFileCreator(new RegionGenerator { Chr = chr }))
6767
{
6868
// Act
69-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath);
70-
var parsedData = parser.Parse();
69+
var parser = new BEDParser<ChIPSeqPeak>();
70+
var parsedData = parser.Parse(file.Path);
7171

7272
// Assert
7373
Assert.True(parsedData.Chromosomes.ContainsKey(chr));
@@ -80,11 +80,11 @@ public void ReadChr(string chr)
8080
public void FailReadChr(string chr)
8181
{
8282
// Arrange
83-
using (var testFile = new TempFileCreator(new RegionGenerator { Chr = "chr1" }))
83+
using (var file = new TempFileCreator(new RegionGenerator { Chr = "chr1" }))
8484
{
8585
// Act
86-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath);
87-
var parsedData = parser.Parse();
86+
var parser = new BEDParser<ChIPSeqPeak>();
87+
var parsedData = parser.Parse(file.Path);
8888

8989
// Assert
9090
Assert.False(parsedData.Chromosomes.ContainsKey(chr));
@@ -96,11 +96,11 @@ public void ReadStrand()
9696
{
9797
// Arrange
9898
var rg = new RegionGenerator();
99-
using (var testFile = new TempFileCreator(rg))
99+
using (var file = new TempFileCreator(rg))
100100
{
101101
// ACt
102-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath);
103-
var parsedData = parser.Parse();
102+
var parser = new BEDParser<ChIPSeqPeak>();
103+
var parsedData = parser.Parse(file.Path);
104104

105105
// Assert
106106
Assert.True(parsedData.Chromosomes[rg.Chr].Strands.ContainsKey(rg.Strand));
@@ -112,11 +112,11 @@ public void ReadLeft()
112112
{
113113
// Arrange
114114
var rg = new RegionGenerator();
115-
using (var testFile = new TempFileCreator(rg))
115+
using (var file = new TempFileCreator(rg))
116116
{
117117
// Act
118-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath);
119-
var parsedData = parser.Parse();
118+
var parser = new BEDParser<ChIPSeqPeak>();
119+
var parsedData = parser.Parse(file.Path);
120120

121121
// Assert
122122
Assert.True(parsedData.Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0].Left == rg.Left);
@@ -127,11 +127,11 @@ public void ReadLeft()
127127
public void FailReadLeft()
128128
{
129129
// Arrange
130-
using (var testFile = new TempFileCreator("chr1\t10V\t20\tGeUtilities_01\t123.4"))
130+
using (var file = new TempFileCreator("chr1\t10V\t20\tGeUtilities_01\t123.4"))
131131
{
132132
// Act
133-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath);
134-
var parsedData = parser.Parse();
133+
var parser = new BEDParser<ChIPSeqPeak>();
134+
var parsedData = parser.Parse(file.Path);
135135

136136
// Assert
137137
Assert.False(parsedData.Chromosomes.ContainsKey("chr1"));
@@ -143,11 +143,11 @@ public void ReadRight()
143143
{
144144
// Arrange
145145
var rg = new RegionGenerator();
146-
using (TempFileCreator testFile = new TempFileCreator(rg))
146+
using (var file = new TempFileCreator(rg))
147147
{
148148
// Act
149-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath);
150-
var parsedData = parser.Parse();
149+
var parser = new BEDParser<ChIPSeqPeak>();
150+
var parsedData = parser.Parse(file.Path);
151151

152152
// Assert
153153
Assert.True(parsedData.Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0].Right == rg.Right);
@@ -158,11 +158,11 @@ public void ReadRight()
158158
public void FailReadRightInvalidValue()
159159
{
160160
// Arrange
161-
using (var testFile = new TempFileCreator("chr1\t10\t20V\tGeUtilities_01\t123.4"))
161+
using (var file = new TempFileCreator("chr1\t10\t20V\tGeUtilities_01\t123.4"))
162162
{
163163
// Act
164-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath);
165-
var parsedData = parser.Parse();
164+
var parser = new BEDParser<ChIPSeqPeak>();
165+
var parsedData = parser.Parse(file.Path);
166166

167167
// Assert
168168
Assert.False(parsedData.Chromosomes.ContainsKey("chr1"));
@@ -173,11 +173,11 @@ public void FailReadRightInvalidValue()
173173
public void FailReadRightColumnIndexOutOfRange()
174174
{
175175
// Arrange
176-
using (var testFile = new TempFileCreator("chr1\t10\t20\tGeUtilities_01\t123.4"))
176+
using (var file = new TempFileCreator("chr1\t10\t20\tGeUtilities_01\t123.4"))
177177
{
178178
// Act
179-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath, new BEDColumns() { Right = 10 });
180-
var parsedData = parser.Parse();
179+
var parser = new BEDParser<ChIPSeqPeak>(new BEDColumns() { Right = 10 });
180+
var parsedData = parser.Parse(file.Path);
181181

182182
// Assert
183183
Assert.False(parsedData.Chromosomes.ContainsKey("chr1"));
@@ -189,11 +189,11 @@ public void ReadName()
189189
{
190190
// Arrange
191191
var rg = new RegionGenerator();
192-
using (var testFile = new TempFileCreator(rg))
192+
using (var file = new TempFileCreator(rg))
193193
{
194194
// Act
195-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath);
196-
var parsedData = parser.Parse();
195+
var parser = new BEDParser<ChIPSeqPeak>();
196+
var parsedData = parser.Parse(file.Path);
197197

198198
// Assert
199199
Assert.True(parsedData.Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0].Name == rg.Name);
@@ -205,11 +205,11 @@ public void ReadValue()
205205
{
206206
// Arrange
207207
var rg = new RegionGenerator();
208-
using (var testFile = new TempFileCreator(rg))
208+
using (var file = new TempFileCreator(rg))
209209
{
210210
// Act
211-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath);
212-
var parsedData = parser.Parse();
211+
var parser = new BEDParser<ChIPSeqPeak>();
212+
var parsedData = parser.Parse(file.Path);
213213

214214
// Assert
215215
Assert.True(parsedData.Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0].Value == rg.Value);
@@ -220,11 +220,11 @@ public void ReadValue()
220220
public void FailReadValue()
221221
{
222222
// Arrange
223-
using (var testFile = new TempFileCreator("chr1\t10\t20\tGeUtilities_01\t123..45"))
223+
using (var file = new TempFileCreator("chr1\t10\t20\tGeUtilities_01\t123..45"))
224224
{
225225
// Act
226-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath);
227-
var parsedData = parser.Parse();
226+
var parser = new BEDParser<ChIPSeqPeak>();
227+
var parsedData = parser.Parse(file.Path);
228228

229229
// Assert
230230
Assert.False(parsedData.Chromosomes.ContainsKey("chr1"));
@@ -236,15 +236,25 @@ public void AssignHashKey()
236236
{
237237
// Arrange
238238
var rg = new RegionGenerator();
239-
using (var testFile = new TempFileCreator(rg))
239+
using (var file = new TempFileCreator(rg))
240240
{
241241
// Act
242-
var parser = new BEDParser<ChIPSeqPeak>(testFile.TempFilePath);
243-
var parsedData = parser.Parse();
242+
var parser = new BEDParser<ChIPSeqPeak>();
243+
var parsedData = parser.Parse(file.Path);
244244

245245
// Assert
246246
Assert.True(parsedData.Chromosomes[rg.Chr].Strands[rg.Strand].Intervals[0].HashKey != 0);
247247
}
248248
}
249+
250+
[Fact]
251+
public void DefaultDelimiterIsTab()
252+
{
253+
// Arrange & Act
254+
var parser = new BEDParser();
255+
256+
// Assert
257+
Assert.True(parser.Delimiter == '\t');
258+
}
249259
}
250260
}

0 commit comments

Comments
 (0)