Skip to content

Commit

Permalink
#95: Add Conversion extensions for BioCollections
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Jun 22, 2020
1 parent 8534d98 commit 5d011fd
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
(preview packages available on nuget)

**Additions:**

* **BioFSharp**:
* [Conversion extensions for BioCollections]()

* **BioFSharp.BioContainers**
* BLAST biocontainer :
* full blastn, blastn-short, megablast, and dc-megablast DSLs
Expand Down
43 changes: 43 additions & 0 deletions src/BioFSharp/BioCollectionsExtensions.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace BioFSharp

open BioSeq
open BioArray
open BioList

[<AutoOpen>]
module BioCollectionsExtensions =
module BioSeq =

[<CompiledName("ToBioArray")>]
let toBioArray (bioSeq:BioSeq<_>) : BioArray<_> = Seq.toArray bioSeq
[<CompiledName("ToBioList")>]
let toBioList (bioSeq:BioSeq<_>) : BioList<_> = Seq.toList bioSeq

[<CompiledName("OfBioArray")>]
let ofBioArray (bioArray:BioArray<_>) : BioSeq<_> = Seq.ofArray bioArray
[<CompiledName("OfBioList")>]
let ofBioList (bioList :BioList<_>) : BioSeq<_> = Seq.ofList bioList

module BioList =

[<CompiledName("ToBioArray")>]
let toBioArray (bioList:BioList<_>) : BioArray<_> = List.toArray bioList
[<CompiledName("ToBioSeq")>]
let toBioSeq (bioList:BioList<_>) : BioSeq<_> = List.toSeq bioList

[<CompiledName("OfBioArray")>]
let ofBioArray (bioArray:BioArray<_>) : BioList<_> = List.ofArray bioArray
[<CompiledName("OfBioSeq")>]
let ofBioSeq (bioSeq:BioSeq<_>) : BioList<_> = List.ofSeq bioSeq

module BioArray =

[<CompiledName("ToBioList")>]
let toBioList (bioArray:BioArray<_>) : BioList<_> = Array.toList bioArray
[<CompiledName("ToBioSeq")>]
let toBioSeq (bioArray:BioArray<_>) : BioSeq<_> = Array.toSeq bioArray

[<CompiledName("OfBioList")>]
let ofBioList (bioList :BioList<_>) : BioArray<_> = Array.ofList bioList
[<CompiledName("OfBioSeq")>]
let ofBioSeq (bioSeq :BioSeq<_>) : BioArray<_> = Array.ofSeq bioSeq
2 changes: 2 additions & 0 deletions src/BioFSharp/BioFSharp.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<Compile Include="BioSeq.fs" />
<Compile Include="BioArray.fs" />
<Compile Include="BioList.fs" />
<Compile Include="BioCollectionsExtensions.fs" />
<Compile Include="AminoProperties.fs" />
<Compile Include="IsoelectricPoint.fs" />
<Compile Include="Digestion.fs" />
Expand Down Expand Up @@ -75,6 +76,7 @@
<None Include="Playground\BioItemsConverter.fsx" />
<None Include="Playground\BioList.fsx" />
<None Include="Playground\BioSeq.fsx" />
<None Include="Playground\BioCollectionsExtensions.fsx" />
<None Include="Playground\Digestion.fsx" />
<None Include="Playground\Elements.fsx" />
<None Include="Playground\Formula.fsx" />
Expand Down
53 changes: 53 additions & 0 deletions src/BioFSharp/Playground/BioCollectionsExtensions.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#r "../../../packages/FSharpAux/lib/netstandard2.0/FSharpAux.dll"

#load "../PhysicalConstants.fs"
#load "../BioID.fs"
#load "../Isotopes.fs"
#load "../Elements.fs"
#load "../Formula.fs"
#load "../Mass.fs"
#load "../IBioItem.fs"
#load "../TaggedSequence.fs"
#load "../IsotopicDistribution.fs"
#load "../ModificationInfo.fs"
#load "../AminoAcidSymbols.fs"
#load "../AminoAcids.fs"
#load "../Nucleotides.fs"
#load "../GlobalModificationInfo.fs"
#load "../BioItemsConverter.fs"
#load "../BioSeq.fs"
#load "../BioArray.fs"
#load "../BioList.fs"
#load "../BioCollectionsExtensions.fs"

open BioFSharp

let testSeq =
BioSeq.ofAminoAcidString "TESTESTESTLUL"

testSeq |> BioSeq.toString

let meem =

testSeq

|> BioList.ofBioSeq
|> BioSeq.toBioList

|> BioArray.ofBioList
|> BioArray.toBioList

|> BioSeq.ofBioList
|> BioSeq.toBioArray

|> BioList.ofBioArray
|> BioList.toBioArray

|> BioSeq.ofBioArray
|> BioSeq.toBioList

|> BioList.toBioSeq
|> BioArray.ofBioSeq
|> BioArray.toBioSeq

(BioSeq.isEqual testSeq meem ) = 0

0 comments on commit 5d011fd

Please sign in to comment.