Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
outillage
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Alice Brenon
outillage
Commits
472dca50
Commit
472dca50
authored
1 year ago
by
Alice Brenon
Browse files
Options
Downloads
Patches
Plain Diff
Add the ability to set the resolution from the command line in the profile visualisation script
parent
a9d97de5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/textometry/visualiseProfile.py
+25
-9
25 additions, 9 deletions
scripts/textometry/visualiseProfile.py
with
25 additions
and
9 deletions
scripts/textometry/visualiseProfile.py
+
25
−
9
View file @
472dca50
...
@@ -12,9 +12,10 @@ def gate(measure):
...
@@ -12,9 +12,10 @@ def gate(measure):
return
[
1
if
i
>=
first
and
i
<
last
else
0
return
[
1
if
i
>=
first
and
i
<
last
else
0
for
i
in
range
(
1
,
1
+
measure
[
'
totalSize
'
])]
for
i
in
range
(
1
,
1
+
measure
[
'
totalSize
'
])]
def
plot
Profile
(
profile
,
outputPath
):
def
plot
Density
(
profile
,
outputPath
):
plot
.
figure
(
figsize
=
(
16
,
13
))
plot
.
figure
(
figsize
=
(
16
,
13
))
ax
=
seaborn
.
lineplot
(
profile
)
l
=
len
(
profile
)
ax
=
seaborn
.
lineplot
(
x
=
[
100
*
i
/
(
l
-
1
)
for
i
in
range
(
l
)],
y
=
profile
)
ax
.
set_xlabel
(
"
Position
"
)
ax
.
set_xlabel
(
"
Position
"
)
ax
.
set_xlim
(
0
,
100
)
ax
.
set_xlim
(
0
,
100
)
ax
.
set_ylim
(
0
)
ax
.
set_ylim
(
0
)
...
@@ -29,7 +30,7 @@ def plotProfile(profile, outputPath):
...
@@ -29,7 +30,7 @@ def plotProfile(profile, outputPath):
def
sumProfiles
(
sameSizeProfiles
):
def
sumProfiles
(
sameSizeProfiles
):
return
list
(
map
(
sum
,
zip
(
*
sameSizeProfiles
)))
return
list
(
map
(
sum
,
zip
(
*
sameSizeProfiles
)))
def
computeProfile
(
measures
,
resolution
=
100
):
def
computeProfile
(
measures
,
resolution
):
bySize
,
count
=
{},
0
bySize
,
count
=
{},
0
for
measure
in
measures
:
for
measure
in
measures
:
distribution
=
gate
(
measure
)
distribution
=
gate
(
measure
)
...
@@ -39,13 +40,28 @@ def computeProfile(measures, resolution=100):
...
@@ -39,13 +40,28 @@ def computeProfile(measures, resolution=100):
bySize
[
l
]
=
[]
bySize
[
l
]
=
[]
bySize
[
l
].
append
(
distribution
)
bySize
[
l
].
append
(
distribution
)
resampled
=
map
(
resample
(
resolution
),
map
(
sumProfiles
,
bySize
.
values
()))
resampled
=
map
(
resample
(
resolution
),
map
(
sumProfiles
,
bySize
.
values
()))
return
[
100
*
x
/
count
for
x
in
sumProfiles
(
list
(
resampled
))]
return
[
resolution
*
x
/
count
for
x
in
sumProfiles
(
list
(
resampled
))]
def
visualiseProfile
(
measures
,
outputPath
):
def
visualiseProfile
(
measures
,
outputPath
,
resolution
=
100
):
profile
=
computeProfile
(
measures
)
profile
=
computeProfile
(
measures
,
resolution
)
toTSV
(
prepare
(
f
"
{
outputPath
}
/profile.tsv
"
),
profile
,
sortBy
=
None
)
toTSV
(
prepare
(
f
"
{
outputPath
}
/profile.tsv
"
),
profile
,
sortBy
=
None
)
plotProfile
(
profile
,
f
"
{
outputPath
}
/profile.png
"
)
plotDensity
(
profile
,
f
"
{
outputPath
}
/profile.png
"
)
def
parseArgs
(
args
):
positional
=
[]
kwargs
=
{}
i
=
0
while
i
<
len
(
args
):
if
args
[
i
]
==
'
--resolution
'
:
kwargs
[
'
resolution
'
]
=
int
(
args
[
i
+
1
])
i
+=
1
else
:
positional
.
append
(
args
[
i
])
i
+=
1
return
positional
,
kwargs
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
visualiseProfile
([
measure
for
_
,
measure
in
fromTSV
(
argv
[
1
]).
iterrows
()],
args
,
kwargs
=
parseArgs
(
argv
[
1
:])
argv
[
2
])
visualiseProfile
([
measure
for
_
,
measure
in
fromTSV
(
args
[
0
]).
iterrows
()],
args
[
1
],
**
kwargs
)
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