Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F87655643
folder_structure.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Oct 14, 00:11
Size
789 B
Mime Type
text/x-python
Expires
Wed, Oct 16, 00:11 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
21596342
Attached To
rSIBORG Simon Botrylloides Regeneration Group
folder_structure.py
View Options
#!/usr/bin/env python
import
sys
import
os
if
__name__
==
'__main__'
:
helpmess
=
"""Usage:
folder_structure species.txt
Creates a subfolder for each species and the corresponding reference within.
"""
# Inputs
if
len
(
sys
.
argv
)
<
2
:
print
(
helpmess
)
sys
.
exit
(
0
)
else
:
infile
=
os
.
path
.
realpath
(
sys
.
argv
[
1
])
with
open
(
infile
,
'r'
)
as
f
:
for
line
in
f
:
# separate the elements
words
=
line
.
strip
()
.
split
()
species
=
(
'./'
+
'_'
.
join
(
words
[
0
:
2
]))
ref
=
(
species
+
'/'
+
'_'
.
join
(
words
[
2
:])
+
'.txt'
)
if
not
os
.
path
.
exists
(
species
):
os
.
mkdir
(
species
)
os
.
chown
(
species
,
1000
,
1000
)
with
open
(
ref
,
'w'
)
as
o
:
o
.
write
(
'original description'
)
Event Timeline
Log In to Comment