Skip to content

Commit c9ae924

Browse files
committed
REF: remove deprecated inline linker syntax
1 parent 93b6a79 commit c9ae924

12 files changed

+374
-452
lines changed

src/GslCore/AstAlgorithms.fs

+1-5
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,7 @@ let decompile tree =
9494
| InlineDna({x=dna; positions=_}) -> appendf "/%s/" dna
9595
| InlineProtein({x=pseq; positions=_}) -> appendf "/$%s/" pseq
9696
| HetBlock(_) -> append "~"
97-
| Gene({x=pg; positions=_}) ->
98-
match pg.linker with
99-
| Some({l1=l1; l2=l2; orient=o}) ->
100-
append (sprintf "%s-%s-%s-%s" l1 l2 o pg.gene)
101-
| None -> append pg.gene
97+
| Gene({x=gene; positions=_}) -> append gene
10298
// part mods
10399
| ParseRelPos({x=rp; positions=_}) ->
104100
_print rp.i state

src/GslCore/AstExpansion.fs

+20-20
Original file line numberDiff line numberDiff line change
@@ -461,13 +461,13 @@ let private expandMut
461461
// Does it contain a mutation modification?
462462
// Make sure we have only one if so.
463463
// TODO: this restriction may not be necessary
464-
match gp.part.mods |> List.choose modIsMutation with
464+
match gp.mods |> List.choose modIsMutation with
465465
| [] -> p
466466
| [mutMod] ->
467-
if (not (gp.part.gene.[0] = 'G' || gp.part.gene.[0] = 'g')) then
467+
if (not (gp.gene.[0] = 'G' || gp.gene.[0] = 'g')) then
468468
failwithf
469469
"Allele swap gene must be g-type e.g gABC1$x1234y. '%c' is not a legal prefix for %s"
470-
(gp.part.gene.[0]) gp.part.gene
470+
(gp.gene.[0]) gp.gene
471471
let rg' = getRG a rgs p.pr
472472

473473
// FIXME: unclear if this was the right behavior, as the rg is selected from both
@@ -492,9 +492,9 @@ let private expandMut
492492
| CTERM -> "Cterm"
493493
| NONETERM -> "No end preference")
494494

495-
if not (rg'.IsValid(gp.part.gene.[1..])) then
495+
if not (rg'.IsValid(gp.gene.[1..])) then
496496
failwithf "Undefined gene '%s' %O\n"
497-
(gp.part.gene.[1..]) (gp.part.where)
497+
(gp.gene.[1..]) (gp.where)
498498

499499
let asAACheck =
500500
match a.pragmas.TryFind("warnoff") with
@@ -520,7 +520,7 @@ let private expandMut
520520
verbose
521521
rg'
522522
codonUsage
523-
gp.part.gene
523+
gp.gene
524524
mutMod
525525
endPref
526526
a.capabilities
@@ -724,10 +724,10 @@ let private expandHB
724724
// but that's embedded down in the mod list
725725

726726
// Assume they must be using a gene part next to a het block. Bad?
727-
if (not (gp.part.gene.StartsWith("g"))) then
728-
failwithf "Heterology block must be adjacent to g part, %s not allowed" gp.part.gene
727+
if (not (gp.gene.StartsWith("g"))) then
728+
failwithf "Heterology block must be adjacent to g part, %s not allowed" gp.gene
729729
let s = translateGenePrefix a.pragmas rg' GENE // Start with standard slice
730-
let startSlice = applySlices verbose gp.part.mods s // Apply modifiers
730+
let startSlice = applySlices verbose gp.mods s // Apply modifiers
731731
let newSlice =
732732
{startSlice with
733733
left =
@@ -739,12 +739,12 @@ let private expandHB
739739
// putting in new consolidated slice.
740740
let newMods =
741741
SLICE(newSlice)
742-
::(gp.part.mods |> List.filter modIsNotSlice)
742+
::(gp.mods |> List.filter modIsNotSlice)
743743

744744
// Prepend backwards as we will flip list at end - watch out, pragmas are reversed as well
745745
scan
746746
a
747-
((GENEPART({gp with part = {gp.part with mods = newMods}}),pr3,fwd3)
747+
((GENEPART({gp with mods = newMods}),pr3,fwd3)
748748
::(INLINEDNA(alt), returnOrFail (pr2.Add("inline")), fwd2)
749749
::(GENEPART(gpUp),pr1,fwd1)
750750
::res)
@@ -778,13 +778,13 @@ let private expandHB
778778
// but that's embedded down in the mod list
779779

780780
// Assume they must be using a gene part next to a het block. Bad?
781-
if not (gp.part.gene.[0] = 'g') then
781+
if not (gp.gene.[0] = 'g') then
782782
failwithf
783783
"Slices adjacent to het block elements ~ must be gene slices - %s has '%c' gene part"
784-
gp.part.gene gp.part.gene.[0]
784+
gp.gene gp.gene.[0]
785785

786786
let s = translateGenePrefix a.pragmas rg'' GENE // Start with standard slice
787-
let startSlice = applySlices verbose gp.part.mods s // Apply modifiers
787+
let startSlice = applySlices verbose gp.mods s // Apply modifiers
788788
let newSlice =
789789
{startSlice with
790790
left =
@@ -796,12 +796,12 @@ let private expandHB
796796
// Assemble new mod list by getting rid of existing slice mods and putting in new consolidated slice.
797797
let newMods =
798798
SLICE(newSlice)
799-
::(gp.part.mods |> List.filter modIsNotSlice)
799+
::(gp.mods |> List.filter modIsNotSlice)
800800
// Prepend backwards as we will flip list at end
801801
// Note - currently destroy any pragmas attached to the heterology block itself
802802
scan
803803
a
804-
((GENEPART({ gp with part = {gp.part with mods = newMods}} ),pr4,fwd4)
804+
((GENEPART({gp with mods = newMods}), pr4, fwd4)
805805
::(INLINEDNA(newInline), returnOrFail (pr2.Add("inline")),fwd2)
806806
::(GENEPART(gpUp),pr1,fwd1)
807807
::res)
@@ -831,11 +831,11 @@ let private expandHB
831831
// but that's embedded down in the mod list
832832

833833
// Assume they must be using a gene part next to a het block. Bad?
834-
assert(gp.part.gene.[0] = 'g')
834+
assert(gp.gene.[0] = 'g')
835835

836836
// now build up the slice again and apply from scratch to the gene
837837
let s = translateGenePrefix a.pragmas rg' GENE // Start with standard slice
838-
let startSlice = applySlices verbose gp.part.mods s // Apply modifiers
838+
let startSlice = applySlices verbose gp.mods s // Apply modifiers
839839

840840
// modify slice to take into account the bit we chopped off
841841
let newSlice =
@@ -860,14 +860,14 @@ let private expandHB
860860
// putting in new consolidated slice.
861861
let newMods =
862862
SLICE(newSlice)
863-
::(gp.part.mods |> List.filter modIsNotSlice)
863+
::(gp.mods |> List.filter modIsNotSlice)
864864
// Prepend backwards as we will flip list at end
865865
// Note - currently destroy pr2 pragmas associated with the hetblock
866866
scan
867867
a
868868
((GENEPART(gpDown),pr4,fwd4)
869869
::(INLINEDNA(newInline), returnOrFail (pr3.Add("inline")),fwd3)
870-
::(GENEPART({gp with part = {gp.part with mods = newMods}}),pr1,fwd1)
870+
::(GENEPART({gp with mods = newMods}), pr1, fwd1)
871871
::res)
872872
tl
873873

src/GslCore/AstProcess.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ let updateDocstringEnvironment = pretransformOnly updateDocstringEnvironmentInne
810810
let private checkGeneName (rgs:GenomeDefs) (library: Map<string, Dna>) assemblyPragmas node =
811811
match node with
812812
| GenePart(pp, gp) ->
813-
let geneName = gp.x.gene.[1..].ToUpper()
813+
let geneName = gp.x.[1..].ToUpper()
814814
let partPragmas = getPragmas pp
815815
getRGNew rgs [partPragmas; assemblyPragmas]
816816
|> mapMessages (fun s -> errorMessage RefGenomeError s node)

src/GslCore/AstTypes.fs

+1-8
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ type Mutation = {f:char; t:char; loc:int; mType:MType}
141141

142142
type Linker = {l1:string; l2:string; orient:string}
143143

144-
type ParseGene = {gene: string; linker:Linker option}
145-
146144
/// Supported binary operations on nodes.
147145
type BinaryOperator = | Add | Subtract | Multiply | Divide
148146

@@ -201,7 +199,7 @@ and AstNode =
201199
| InlineDna of Node<string>
202200
| InlineProtein of Node<string>
203201
| HetBlock of Node<unit>
204-
| Gene of Node<ParseGene>
202+
| Gene of Node<string>
205203
| Assembly of Node<AstNode list>
206204
// AST nodes for Level 2 syntax support
207205
| L2Id of Node<L2Id>
@@ -614,11 +612,6 @@ let createPart mods pragmas basePart =
614612
/// Create a top-level part with empty collections and default values from a base part.
615613
let createPartWithBase = createPart [] []
616614

617-
/// Create a top-level part given a gene ID.
618-
let createGenePart (gene: PString) (linker: Linker option) =
619-
// The base part for this part will be a Gene AST node.
620-
createPartWithBase (Gene({x = {gene = gene.i; linker = linker}; positions = [gene.pos]}))
621-
622615
/// Capture a list of parsed mods and stuff them into their associated part.
623616
let stuffModsIntoPart astPart mods =
624617
match astPart with

src/GslCore/Constants.fs

-5
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ let defaultRefGenome = "cenpk"
3131

3232
let aaLegal = "ACDEFGHIKLMNPQRSTVWY*" |> Set.ofSeq
3333

34-
/// List of approved linker abbreviations.
35-
let legalLinkers =
36-
[ '0' .. '9' ] @ [ 'A'..'E']
37-
|> List.map (fun c -> sprintf "%c" c) |> Set.ofSeq
38-
3934
[<Measure>] type OneOffset
4035
[<Measure>] type ZeroOffset
4136

src/GslCore/DnaCreation.fs

+25-29
Original file line numberDiff line numberDiff line change
@@ -153,24 +153,24 @@ let getRG (a:Assembly) (rgs:GenomeDefs) (pr:PragmaCollection) =
153153
| Bad(msgs) -> failwith msgs.[0]
154154

155155
/// Take a genepart and slices and get the actual DNA sequence.
156-
let realizeSequence verbose (pragmas:PragmaCollection) fwd (rg:GenomeDef) (gp:GenePartWithLinker) =
156+
let realizeSequence verbose (pragmas:PragmaCollection) fwd (rg:GenomeDef) (gp:GenePart) =
157157

158158
if verbose then
159159
printf "realizeSequence: fetch fwd=%s %s\n"
160-
(if fwd then "y" else "n") gp.part.gene
160+
(if fwd then "y" else "n") gp.gene
161161

162162
// Inspect prefix of gene e.g g,t,o,p and see what type of gene part we are starting with
163163
// Description of part to give in case of error
164-
let errorDesc = gp.part.gene
165-
let genePart = lookupGenePart errorDesc (gp.part.gene.[0]) (gp.part.mods)
164+
let errorDesc = gp.gene
165+
let genePart = lookupGenePart errorDesc (gp.gene.[0]) (gp.mods)
166166

167167
// Lookup gene location
168-
let feat = rg.get(gp.part.gene.[1..])
168+
let feat = rg.get(gp.gene.[1..])
169169

170170
// Come up with an initial slice based on the gene prefix type
171171
let s = translateGenePrefix pragmas rg genePart
172172

173-
let finalSlice = applySlices verbose gp.part.mods s
173+
let finalSlice = applySlices verbose gp.mods s
174174
let left = adjustToPhysical feat finalSlice.left
175175
let right = adjustToPhysical feat finalSlice.right
176176

@@ -241,11 +241,7 @@ let expandGenePart
241241
(a:Assembly)
242242
specifiedDnaSource
243243
(ppp:PPP)
244-
(gp:GenePartWithLinker) =
245-
246-
match gp.linker with
247-
| None -> () // No linkers were present
248-
| Some(l) -> checkLinker l // Test the linkers
244+
(gp:GenePart) =
249245

250246
// If the dna source is empty, then we are going to pull the DNA
251247
// part from the default reference genome, so we should make the
@@ -256,7 +252,7 @@ let expandGenePart
256252

257253
// Check the genes are legal
258254
//let prefix = gp.part.gene.[0]
259-
let g = gp.part.gene.[1..].ToUpper()
255+
let g = gp.gene.[1..].ToUpper()
260256
let rg' = getRG a rgs ppp.pr
261257

262258
if not (rg'.IsValid(g)) then
@@ -268,21 +264,21 @@ let expandGenePart
268264
// Need to adjust for any slicing carefully since the DNA island is small
269265
// Validate mods to gene
270266
let errorRef = match a.name with | None -> sprintf "%A" a | Some(x) -> x
271-
validateMods errorRef gp.part.where gp.part.mods
267+
validateMods errorRef gp.where gp.mods
272268

273269
// Come up with an initial slice based on the gene prefix type
274270

275271
// Get standard slice range for a gene
276272
let s = translateGenePrefix a.pragmas rg' GENE
277-
let finalSlice = applySlices verbose gp.part.mods s
273+
let finalSlice = applySlices verbose gp.mods s
278274

279275
// Ban approx slices to stay sane for now
280276
if finalSlice.lApprox || finalSlice.rApprox then
281277
failwithf
282278
"sorry, approximate slices of library genes not supported yet in %A\n"
283279
(prettyPrintAssembly a)
284280

285-
let sliceContext = Library(gp.part.gene)
281+
let sliceContext = Library(gp.gene)
286282

287283
let x, y =
288284
getBoundsFromSlice finalSlice dna.Length sliceContext
@@ -295,8 +291,8 @@ let expandGenePart
295291
let orfAnnotation = orfAnnotationFromSlice finalSlice finalDNA.Length ppp.fwd sliceContext
296292

297293
let name1 =
298-
if gp.part.mods.Length = 0 then gp.part.gene
299-
else (gp.part.gene + (printSlice finalSlice))
294+
if gp.mods.Length = 0 then gp.gene
295+
else (gp.gene + (printSlice finalSlice))
300296
let name2 = if ppp.fwd then name1 else "!"+name1
301297

302298
{id = None;
@@ -325,11 +321,11 @@ let expandGenePart
325321
materializedFrom = Some(ppp);
326322
annotations = [Orf(orfAnnotation)]}
327323
else // no :( - wasn't in genome or library
328-
failwithf "undefined gene '%s' %O\n" g gp.part.where
324+
failwithf "undefined gene '%s' %O\n" g gp.where
329325
else
330326
// Inspect prefix of gene e.g g,t,o,p and see what type of gene part we are starting with
331-
let errorDesc = gp.part.gene
332-
let genePart = lookupGenePart errorDesc (gp.part.gene.[0]) (gp.part.mods)
327+
let errorDesc = gp.gene
328+
let genePart = lookupGenePart errorDesc gp.gene.[0] gp.mods
333329
// Lookup gene location
334330
let rg' = getRG a rgs ppp.pr
335331

@@ -354,13 +350,13 @@ let expandGenePart
354350
// Validate mods to gene
355351
let errorRef = match a.name with | None -> sprintf "%A" a | Some(x) -> x
356352

357-
validateMods errorRef gp.part.where gp.part.mods
353+
validateMods errorRef gp.where gp.mods
358354
// Come up with an initial slice based on the gene prefix type
359355
let s = translateGenePrefix a.pragmas rg' genePart
360356
if verbose then printf "log: processing %A\n" a
361357

362358
// finalSlice is the consolidated gene relative coordinate of desired piece
363-
let finalSlice = applySlices verbose gp.part.mods s
359+
let finalSlice = applySlices verbose gp.mods s
364360

365361
// Gene relative coordinates for the gene slice we want
366362
let finalSliceWithApprox =
@@ -409,7 +405,7 @@ let expandGenePart
409405
if (left > right && feat.fwd) || (right>left && (not feat.fwd)) then
410406
failwithf
411407
"slice results in negatively lengthed DNA piece for %s\n"
412-
(gp.part.gene + (printSlice finalSlice))
408+
(gp.gene + (printSlice finalSlice))
413409

414410
/// left' is the genomic coordinate of the start of the element (i.e gene upstream)
415411
let left', right' = if feat.fwd then left, right else right, left
@@ -431,15 +427,15 @@ let expandGenePart
431427
|> DnaOps.revCompIf (not ppp.fwd)
432428

433429
let description1 =
434-
match gp.part.mods with
435-
| [] -> gp.part.gene
430+
match gp.mods with
431+
| [] -> gp.gene
436432
| [DOTMOD(d)] ->
437433
match d with
438-
| "up" -> "u" + gp.part.gene.[1..]
439-
| "down" -> "d" + gp.part.gene.[1..]
440-
| "mrna" -> "m" + gp.part.gene.[1..]
434+
| "up" -> "u" + gp.gene.[1..]
435+
| "down" -> "d" + gp.gene.[1..]
436+
| "mrna" -> "m" + gp.gene.[1..]
441437
| x -> failwithf "unimplemented DOTMOD %s" x
442-
| _ -> "g" + gp.part.gene.[1..] + (printSlice finalSlice)
438+
| _ -> "g" + gp.gene.[1..] + (printSlice finalSlice)
443439
let description2 = if ppp.fwd then description1 else "!"+description1
444440

445441
let promStart = {x = -300<OneOffset>; relTo = FivePrime}

0 commit comments

Comments
 (0)