Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EW control
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
whuie2
EW control
Commits
00cc796e
"git@gitlab.engr.illinois.edu:cs525-sp18-g07/spark.git" did not exist on "ed92b47e83c2882f0e76da78dc268577df820382"
Commit
00cc796e
authored
2 years ago
by
Yb Tweezer
Browse files
Options
Downloads
Patches
Plain Diff
redo SuperSequence.save as files in directory
parent
ea3daab8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/sequences.py
+25
-20
25 additions, 20 deletions
lib/sequences.py
with
25 additions
and
20 deletions
lib/sequences.py
+
25
−
20
View file @
00cc796e
...
...
@@ -5,6 +5,8 @@ from .plotdefs import Plotter
import
copy
import
pathlib
import
toml
import
shutil
import
os
"""
Builds on abstractions defined in lib.structures.
...
...
@@ -15,13 +17,18 @@ def _titlecase(s: str) -> str:
for
_s
in
s
.
replace
(
"
"
,
"
_
"
).
split
(
"
_
"
))
def
_fresh_filename
(
path
:
pathlib
.
Path
,
overwrite
:
bool
=
False
)
->
pathlib
.
Path
:
if
overwrite
:
return
path
_path
=
path
while
_path
.
is_file
():
print
(
f
"
WARNING: found existing file
{
_path
}
"
)
_path
=
_path
.
parent
.
joinpath
(
_path
.
stem
+
"
_
"
+
_path
.
suffix
)
print
(
f
"
Write instead to
{
_path
}
"
)
while
_path
.
exists
():
print
(
f
"
WARNING:
{
_path
}
exists in filesystem
"
)
if
overwrite
:
print
(
f
"
:: rm -rf
{
_path
}
"
)
if
_path
.
is_dir
():
shutil
.
rmtree
(
str
(
_path
))
else
:
os
.
remove
(
str
(
_path
))
else
:
_path
=
_path
.
parent
.
joinpath
(
_path
.
stem
+
"
_
"
+
_path
.
suffix
)
print
(
f
"
Write instead to
{
_path
}
"
)
return
_path
def
min_n
(
generator
,
default
=
None
):
...
...
@@ -55,7 +62,7 @@ class SuperSequence:
"""
def
__init__
(
self
,
outdir
:
pathlib
.
Path
,
name
:
str
,
sequences
:
dict
[
str
,
Sequence
]
=
None
,
sequences
:
dict
[
str
,
Sequence
]
=
None
,
params
:
dict
[
str
,
...]
=
None
,
defaults
:
ConnectionLayout
=
None
):
"""
Constructor.
...
...
@@ -70,6 +77,7 @@ class SuperSequence:
self
.
outdir
=
outdir
self
.
name
=
name
self
.
sequences
=
dict
()
if
sequences
is
None
else
sequences
self
.
params
=
dict
()
if
params
is
None
else
params
self
.
defaults
=
defaults
def
__getitem__
(
self
,
key
:
str
)
->
Sequence
:
...
...
@@ -154,21 +162,18 @@ class SuperSequence:
def
save
(
self
,
target
:
pathlib
.
Path
=
None
,
overwrite
:
bool
=
False
,
printflag
:
bool
=
True
):
T
=
self
.
outdir
.
joinpath
(
self
.
name
)
if
target
is
None
else
target
T
=
T
.
parent
.
joinpath
(
T
.
name
+
"
.toml
"
)
if
T
.
suffix
!=
"
.toml
"
else
T
if
printflag
:
print
(
f
"
[sequencing] Saving sequence data to
'
{
T
}
'
:
"
)
sequence_file
=
_fresh_filename
(
T
,
overwrite
)
if
printflag
:
print
(
f
"
[sequencing] save sequence
'
{
sequence_file
.
stem
}
'"
)
print
(
sequence_file
.
parent
.
is_dir
())
print
(
sequence_file
.
exists
())
if
not
sequence_file
.
parent
.
is_dir
():
print
(
f
"
:: mkdir -p
'
{
sequence_file
.
parent
}
'"
)
sequence_file
.
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
print
(
sequence_file
.
parent
.
is_dir
())
sequence_file
=
sequence_file
.
parent
.
joinpath
(
sequence_file
.
name
)
print
(
sequence_file
)
print
(
sequence_file
.
parent
.
is_dir
())
with
sequence_file
.
open
(
'
w
'
)
as
outfile
:
T
=
_fresh_filename
(
T
,
overwrite
)
T_seq
=
T
.
joinpath
(
"
sequence.toml
"
)
T_par
=
T
.
joinpath
(
"
parameters.toml
"
)
if
not
T
.
is_dir
():
print
(
f
"
:: mkdir -p
'
{
T
}
'"
)
T
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
with
T_seq
.
open
(
'
w
'
)
as
outfile
:
toml
.
dump
(
self
.
to_primitives
(),
outfile
)
with
T_par
.
open
(
'
w
'
)
as
outfile
:
toml
.
dump
(
self
.
params
,
outfile
)
return
self
@staticmethod
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment