reflexive 1.2.4__py3-none-any.whl → 1.2.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- reflexive/res.py +17 -3
- reflexive/res_functions.py +62 -0
- {reflexive-1.2.4.dist-info → reflexive-1.2.6.dist-info}/METADATA +1 -1
- {reflexive-1.2.4.dist-info → reflexive-1.2.6.dist-info}/RECORD +6 -5
- {reflexive-1.2.4.dist-info → reflexive-1.2.6.dist-info}/WHEEL +0 -0
- {reflexive-1.2.4.dist-info → reflexive-1.2.6.dist-info}/licenses/LICENSE +0 -0
reflexive/res.py
CHANGED
|
@@ -121,6 +121,7 @@ class Res_display:
|
|
|
121
121
|
#Get RE sequence
|
|
122
122
|
df = self._add_res_sequence(df)
|
|
123
123
|
df = self._add_res_interactions(df)
|
|
124
|
+
df = self._add_res_weights(df)
|
|
124
125
|
df = self._add_res_adj_matrix(df)
|
|
125
126
|
return df
|
|
126
127
|
|
|
@@ -140,9 +141,14 @@ class Res_display:
|
|
|
140
141
|
temp_df['res_interactions'] = temp_df.res_sequence.apply(self._count_res_interactions)
|
|
141
142
|
return temp_df
|
|
142
143
|
|
|
144
|
+
def _add_res_weights(self,df):
|
|
145
|
+
temp_df = df.copy()
|
|
146
|
+
temp_df['res_weights'] = temp_df.res_interactions.apply(self._calc_res_weights)
|
|
147
|
+
return temp_df
|
|
148
|
+
|
|
143
149
|
def _add_res_adj_matrix(self,df):
|
|
144
150
|
temp_df = df.copy()
|
|
145
|
-
temp_df['res_adj_matrix'] = temp_df.
|
|
151
|
+
temp_df['res_adj_matrix'] = temp_df.res_weights.apply(self._create_adj_matrix)
|
|
146
152
|
return temp_df
|
|
147
153
|
|
|
148
154
|
def _get_res_sequence(self,reflexive_expressions):
|
|
@@ -180,7 +186,15 @@ class Res_display:
|
|
|
180
186
|
re_ints[rei] += 1
|
|
181
187
|
return re_ints
|
|
182
188
|
|
|
183
|
-
def
|
|
189
|
+
def _calc_res_weights(self,interactions:dict[tuple,int])->dict[tuple,float]:
|
|
190
|
+
max_count = max(interactions.values())
|
|
191
|
+
weights = dict()
|
|
192
|
+
for edge,count in interactions.items():
|
|
193
|
+
weights[edge] = round(count/(15*max_count),3)
|
|
194
|
+
return weights
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def _create_adj_matrix(self,weights:dict[tuple,float])->list[list[float]]:
|
|
184
198
|
re_types = ["RR","NR","AR","AF","EP"]
|
|
185
199
|
matrix = []
|
|
186
200
|
for r in re_types:
|
|
@@ -188,7 +202,7 @@ class Res_display:
|
|
|
188
202
|
for c in re_types:
|
|
189
203
|
key = tuple(sorted((r,c)))
|
|
190
204
|
#print(key)
|
|
191
|
-
weight =
|
|
205
|
+
weight = weights.get(key,0)
|
|
192
206
|
row.append(weight)
|
|
193
207
|
matrix.append(row)
|
|
194
208
|
return matrix
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# import text into dataframe
|
|
2
|
+
# accepts either an iterable of strings, or an iterable over text files
|
|
3
|
+
# returns a pandas series iterable of type string
|
|
4
|
+
|
|
5
|
+
# clean text and calculate length
|
|
6
|
+
# accepts an iterable of strings in form of pandas series of type string
|
|
7
|
+
# returns a pandas series iterable of type int
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# chunk text and keep original index ref
|
|
11
|
+
# accepts an iterable of dataframe rows
|
|
12
|
+
# returns an iterable of dataframe rows with added column 'text_chunks' - list of strings
|
|
13
|
+
|
|
14
|
+
# upload docs to s3 and save local copy - side effects
|
|
15
|
+
# accepts an iterable of iterable of chunks (with ids)
|
|
16
|
+
# returns an an iterable of s3 responses? URLs to S3 file?
|
|
17
|
+
|
|
18
|
+
# initiate custom entity job on comprehend
|
|
19
|
+
# no parameters
|
|
20
|
+
# returns job id for checking status, and downloading
|
|
21
|
+
|
|
22
|
+
# check status
|
|
23
|
+
# accepts job id
|
|
24
|
+
# returns status
|
|
25
|
+
|
|
26
|
+
# download results
|
|
27
|
+
# accepts job id
|
|
28
|
+
# returns iterable of results
|
|
29
|
+
|
|
30
|
+
# unpack results and load into dataframe
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# extract reflexive expressions into dataframe
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# get reflexive sequences
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# get interactions
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# create count adj matrix
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# create weighted adj matrix
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# save dataframe to file
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# visualise expressions in text
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# visualise reflexive sequence
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# visualise res graph
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
#
|
|
61
|
+
# Network analysis functions
|
|
62
|
+
#
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
reflexive/__init__.py,sha256=x5l8GV_9yC8yJyjTLqiM_WkfuPMLuNgQxF6PIz5MfFU,422
|
|
2
2
|
reflexive/analyse.py,sha256=CU6mQ8PxQrkOvuSe4mmnuI18jGMkuxql3zLZ1vEeMEY,17466
|
|
3
3
|
reflexive/cfg.py,sha256=tDPiC9NwpEVoT05_831sMsMfHhJt8pVrSOsgbtzTNDM,4267
|
|
4
|
-
reflexive/res.py,sha256=
|
|
4
|
+
reflexive/res.py,sha256=OUuki0BW9_OvHUSR5FLwqiCoQKjTeZa41of8oA4X8dI,7444
|
|
5
|
+
reflexive/res_functions.py,sha256=YF45yUF8NYMSC19DFpE0lmV4xyNxv3QqbbzZmdwmFzg,1231
|
|
5
6
|
reflexive/session.py,sha256=8STWo8sqmWn-1PHcloFbgmLEvd7lsiFTU4t7ESRTsvw,10046
|
|
6
7
|
reflexive/util.py,sha256=uU7-lqUmiCiCaR85AdNFKXrdrBspjb1Rmd-yThA3fRU,3699
|
|
7
8
|
reflexive/visualise.py,sha256=pVnsPJOnHiLAIvDDm9P0u6-sGQINC4GVOY9b0GrzTK4,11725
|
|
8
|
-
reflexive-1.2.
|
|
9
|
-
reflexive-1.2.
|
|
10
|
-
reflexive-1.2.
|
|
11
|
-
reflexive-1.2.
|
|
9
|
+
reflexive-1.2.6.dist-info/METADATA,sha256=UFScd71_jEuuXDIbGOScKNbbpEiQiv9cmL-ZD6DVZVE,574
|
|
10
|
+
reflexive-1.2.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
11
|
+
reflexive-1.2.6.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
12
|
+
reflexive-1.2.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|