Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additions to IntervalList. #10

Merged
merged 1 commit into from
May 19, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/java/htsjdk/samtools/util/IntervalList.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,17 @@ public static IntervalList fromFile(final File file) {
return list;
}

/**
* Calls {@link #fromFile(java.io.File)} on the provided files, and returns their {@link #union(java.util.Collection)}.
*/
public static IntervalList fromFiles(final Collection<File> intervalListFiles) {
final Collection<IntervalList> intervalLists = new ArrayList<IntervalList>();
for (final File file : intervalListFiles) {
intervalLists.add(IntervalList.fromFile(file));
}
return IntervalList.union(intervalLists);
}

/**
* Parses an interval list from a reader in a stream based fashion.
* @param in a BufferedReader that can be read from
Expand Down Expand Up @@ -579,7 +590,22 @@ public static IntervalList difference(final Collection<IntervalList> lists1, fin
}


@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

final IntervalList intervals1 = (IntervalList) o;

return header.equals(intervals1.header) && intervals.equals(intervals1.intervals);
}

@Override
public int hashCode() {
int result = header.hashCode();
result = 31 * result + intervals.hashCode();
return result;
}
}
/**
* Comparator that orders intervals based on their sequence index, by coordinate
Expand Down