Skip to content

Instantly share code, notes, and snippets.

View jamessdixon's full-sized avatar

Jamie Dixon jamessdixon

View GitHub Profile
@jamessdixon
jamessdixon / high_order_hypedsearch
Created May 30, 2023 12:50
Using Higher Order Functions In Hypedsearch
#original
def do_fourth_thing(spectrum, b_sorted_clusters, y_sorted_clusters, prec_tol):
start_time = time.time()
hybrid_merged = clustering.get_hybrid_matches(b_sorted_clusters, y_sorted_clusters, spectrum.precursor_mass, prec_tol, spectrum.precursor_charge)
end_time = time.time() - start_time
with open('Timing_data.txt', 'a') as t:
t.write("Finding hybrid merges took:" + '\t' + str(end_time) + "\n")
return hybrid_merged
#reduces to
@jamessdixon
jamessdixon / matched_hits_print
Created May 29, 2023 01:53
print out matched_hits
def write_masses_to_disk(matched_masses, flavor):
file_name = 'matched_masses_' + flavor + '.csv'
with open(file_name, 'w') as t:
header = 'precursor_weight'+ '\t'+ 'matched_weight'+ '\t'+ 'start_index'+ '\t'+ 'end_index'+ '\t'+ 'b_ion'+ '\t'+ 'single_charge'+ '\t'+ 'protein_number'+ "\n"
t.write(header)
for key, values in matched_masses.items():
for value in values:
first,second,third,fourth,fifth,sixth = value
item = str(key) + '\t' + str(first)+ '\t' + str(second)+ '\t' + str(third)+ '\t' + str(fourth)+ '\t' + str(fifth)+ '\t' + str(sixth) + "\n"
with open(file_name, 'a') as t:
@jamessdixon
jamessdixon / longestConsecutiveSequenece.fsx
Created February 27, 2022 15:59
Longest Consecutive Sequence In a Sequence of Ints
//Given an unsorted array of integers, return the length of ther longest
//consecutive elements sequence where the integers
//in the sequence are in inremental order.
//eg: [2,1,2,6,4,5,1,7] -> [1,2,4,5,7]
open System
type Token = {Index: int; Number:int}
@jamessdixon
jamessdixon / Covid
Created December 19, 2020 21:01
Looking at the COVID Genome Using F#
open System
open System.IO
let path = "/Users/jamesdixon/Downloads/sequence.fasta"
let file = File.ReadAllText(path)
let totalLength = file.Length
let prefixLength = 97
let suffixLength = 2
let stringSequence = file.Substring(prefixLength,totalLength-prefixLength-suffixLength)
@jamessdixon
jamessdixon / BioinformnaticsFrequentWords.fsx
Created September 23, 2020 12:01
BioinformnaticsFrequentWords
let frequentWords (text:string) (k:int) =
let patternCounts =
text
|> Seq.windowed k
|> Seq.map(fun c -> new string(c))
|> Seq.countBy(fun s -> s)
|> Seq.sortByDescending(fun (s,c) -> c)
let maxCount = patternCounts |> Seq.head |> snd
patternCounts
|> Seq.filter(fun (s,c) -> c = maxCount)
@jamessdixon
jamessdixon / BioinformnaticsPatternCount
Created September 15, 2020 19:15
Bioinformatics: Pattern Count
let patternCount (text:string) (pattern:string) =
text
|> Seq.windowed pattern.Length
|> Seq.map(fun c -> new string(c))
|> Seq.filter(fun s -> s = pattern)
|> Seq.length
let text = "ACAACTCTGCATACTATCGGGAACTATCCT"
let pattern = "ACTAT"
patternCount text pattern
@jamessdixon
jamessdixon / WebCrawling
Last active December 19, 2019 20:53
WebCrawling With F#
#r @"C:\Users\DIXON2019\.nuget\packages\microsoft.azure.storage.blob\11.1.0\lib\netstandard2.0\Microsoft.Azure.Storage.Blob.dll"
#r @"C:\Users\DIXON2019\.nuget\packages\microsoft.azure.storage.common\11.1.0\lib\netstandard2.0\Microsoft.Azure.Storage.Common.dll"
#r @"C:\Users\DIXON2019\.nuget\packages\microsoft.azure.cosmos.table\1.0.5\lib\netstandard2.0\Microsoft.Azure.Cosmos.Table.dll"
#r @"C:\Users\DIXON2019\.nuget\packages\microsoft.azure.documentdb.core\2.1.3\lib\netstandard1.6\Microsoft.Azure.DocumentDB.Core.dll"
open System
open System.Net
open System.Windows.Forms
@jamessdixon
jamessdixon / FSAuth0
Created February 21, 2019 01:19
Auth0 with F#
namespace sameroom.mobile.iOS
open System
open Xamarin.Forms
open sameroom.mobile
open Auth0.OidcClient
type LoginParameters = { audience : string }
type AuthenticationService() =
namespace ChickenSoftware.PanzerGeneral
open System.IO
open FSharp.Data
open Xamarin.Forms
open System.Reflection
type TileContext = JsonProvider<"Data//Scenario_Tile.json">
type UnitContext = JsonProvider<"Data//Scenario_Unit.json">
type EquipmentContext = JsonProvider<"Data//Equipment.json">
#r "System.Xml.Linq.dll"
#r "Newtonsoft.Json"
open System.IO
open System.Xml
open System.Xml.Linq
open Newtonsoft.Json
let convert xmlPath jsonPath =