This repository was archived by the owner on May 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Parser file added. #7
Open
eksytnik
wants to merge
2
commits into
AleksandrSl:development
Choose a base branch
from
eksytnik:development
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| def parsing_bed(bed_file): | ||
| def check_int(line): | ||
| try: | ||
| line[1], line[2] = int(line[1]), int(line[2]) | ||
| except ValueError: | ||
| raise ValueError("Program expects starting and " | ||
| "ending positions to be valid " | ||
| "numbers (integer). Check line: {} " | ||
| .format(' '.join(line))) | ||
| return line | ||
|
|
||
| def check_len(line): | ||
| try: | ||
| line[2] | ||
| except IndexError: | ||
| raise IndexError("Program expects each line to " | ||
| "have chromosome name, starting " | ||
| "and ending position. Check line: {} " | ||
| .format(' '.join(line))) | ||
| return line | ||
|
|
||
| parsed_data = list() | ||
| with open(bed_file) as input_handle: | ||
| for line in input_handle: | ||
| line_elements = line.split() | ||
| # Ignore annotation lines. | ||
| if any(el in line_elements for el in ("#", "browser", "track")): | ||
| continue | ||
| check_len(line_elements) | ||
| check_int(line_elements) | ||
| parsed_data.append(tuple(line_elements[0:5])) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the fourth element?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Realised we shoud either take 4 or 6 elements, not 5...
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we can ignore it for the moment |
||
| return parsed_data | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why line, not smth like elements?) And why not
if len(line) < 3: