Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
GenDB3
lib.intervals
Commits
ecaf2588
Commit
ecaf2588
authored
Jan 13, 2014
by
Lukas Jelonek
Browse files
Fixed bugs in IdentifyIntervalsFromMemberlist
parent
ee06943b
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/cebitec/common/sequencetools/intervals/IdentifyIntervalsFromMemberlist.java
View file @
ecaf2588
...
...
@@ -155,8 +155,9 @@ public class IdentifyIntervalsFromMemberlist {
* Calculates all subintervals from the given members that are located in the given global interval coordinates.
*
* @param <T>
* @param members
* @param interval
* @param members A list of member. Must not be null.
* @param interval An interval in the global coordinate system. If the interval is empty it is not only checked
* whether the interval is overlapping with an existing interval, but if it is adjacent.
* @return
*/
public
static
<
T
>
List
<
MemberResult
<
T
>>
identifySubintervals
(
List
<?
extends
Member
<?
extends
T
>>
members
,
Interval
<
Integer
>
interval
)
{
...
...
@@ -166,7 +167,7 @@ public class IdentifyIntervalsFromMemberlist {
for
(
Member
<?
extends
T
>
member
:
members
)
{
final
Interval
<
Integer
>
global
=
member
.
getGlobalInterval
();
Interval
<
Integer
>
local
=
null
;
if
(
interval
.
isEmpty
()
&&
operations
.
contains
(
global
,
interval
))
{
if
(
interval
.
isEmpty
()
&&
(
operations
.
contains
(
global
,
interval
)
||
operations
.
adjacent
(
global
,
interval
))
)
{
local
=
operations
.
shift
(
interval
,
-
global
.
getStart
());
MemberResult
<
T
>
result
=
new
MemberResult
<>(
member
.
getId
(),
local
);
list
.
add
(
result
);
...
...
src/test/java/de/cebitec/common/sequencetools/intervals/IdentifyIntervalsFromMemberlistTest.java
View file @
ecaf2588
...
...
@@ -71,6 +71,20 @@ public class IdentifyIntervalsFromMemberlistTest {
hasItems
(
new
MemberResult
<>(
"s3"
,
createInterval
(
0
,
0
))));
}
@Test
public
void
testIdentifySubintervalsEmtpyIntervalAtEnd
()
{
assertThat
(
identifySubintervals
(
list
,
createInterval
(
9
,
9
)),
hasItems
(
new
MemberResult
<>(
"s4"
,
createInterval
(
3
,
3
))));
}
@Test
public
void
testIdentifySubintervalsEmtpyIntervalAtBeginning
()
{
List
<
MemberResult
<
String
>>
identifySubintervals
=
identifySubintervals
(
list
,
createInterval
(
0
,
0
));
MemberResult
<
String
>
expected
=
new
MemberResult
<>(
"s1"
,
createInterval
(
0
,
0
));
assertThat
(
identifySubintervals
,
hasItems
(
expected
));
}
@Test
public
void
testIdentifySubintervalsMultipleInternalIntervals
()
{
assertThat
(
identifySubintervals
(
list
,
createInterval
(
5
,
8
)),
...
...
src/test/java/de/cebitec/common/sequencetools/intervals/SerializableIntervalTest.java
0 → 100644
View file @
ecaf2588
/*
* Copyright (C) 2014 Lukas Jelonek <ljelonek at cebitec.uni-bielefeld.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
de.cebitec.common.sequencetools.intervals
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
hamcrest
.
Matchers
.*;
import
static
de
.
cebitec
.
common
.
sequencetools
.
intervals
.
Intervals
.*;
/**
*
* @author Lukas Jelonek <ljelonek at cebitec.uni-bielefeld.de>
*/
public
class
SerializableIntervalTest
{
@Test
public
void
testEqualsEmptyIntervals
()
{
assertThat
(
createInterval
(
0
,
0
),
equalTo
(
createInterval
(
0
,
0
)));
}
@Test
public
void
testEqualsEmptyIntervals2
()
{
assertThat
(
createInterval
(
1
,
1
),
equalTo
(
createInterval
(
1
,
1
)));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment