-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from CSBiology/feature-minimalParser-#5
#5 Minimal parser
- Loading branch information
Showing
7 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
namespace FsOboParser | ||
|
||
//open OboTerm | ||
|
||
//open type OboTerm | ||
|
||
|
||
////######################################## | ||
|
This file contains 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
This file contains 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,30 @@ | ||
namespace FsOboParser | ||
|
||
|
||
/// Functions for working with OboEntries. | ||
module OboEntries = | ||
|
||
/// Reads a collection of strings and parses them into a list of OboEntries. | ||
let fromLines verbose (input : seq<string>) = | ||
|
||
let en = input.GetEnumerator() | ||
let rec loop (en : System.Collections.Generic.IEnumerator<string>) entries lineNumber = | ||
|
||
match en.MoveNext() with | ||
| true -> | ||
match (en.Current |> DBXref.trimComment) with | ||
| "[Term]" -> | ||
let lineNumber, parsedTerm = OboTerm.fromLines verbose en lineNumber "" "" false [] "" "" [] [] [] [] [] [] [] [] false [] [] [] false "" "" | ||
loop en (Term parsedTerm :: entries) lineNumber | ||
| "[Typedef]" -> | ||
let lineNumber, parsedTypeDef = OboTypeDef.fromLines verbose en lineNumber "" "" "" "" [] [] false false false false false false false | ||
loop en (TypeDef parsedTypeDef :: entries) lineNumber | ||
| _ -> loop en entries (lineNumber + 1) | ||
| false -> entries | ||
|
||
loop en [] 1 | ||
|
||
/// Reads an OBO file and returns a list of OboEntries. | ||
let fromFile verbose filepath = | ||
System.IO.File.ReadAllLines filepath | ||
|> fromLines verbose |
This file contains 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,7 @@ | ||
namespace FsOboParser | ||
|
||
|
||
/// Model of raw OboEntries, divided into Terms (as `OboTerm`s) and TypeDefs (as `OboTypeDef`s). | ||
type OboEntry = | ||
| Term of OboTerm | ||
| TypeDef of OboTypeDef |
This file contains 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
This file contains 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