In [ ]:
import pandas as pd
import subprocess
mv Untitled.jar ConnectedComponents.jar
worked:
badger:Neo4j_meta4 janet$ pwd
/Users/janet/Neo4j_meta4
badger:Neo4j_meta4 janet$ java -jar ConnectedComponents.jar 0.03
In [ ]:
subprocess.check_output(['echo', 'hello'])
In [ ]:
! pwd
In [ ]:
! ls -l ../ConnectedComponents.jar
In [ ]:
example_result = subprocess.check_output(['java', '-jar', '../ConnectedComponents.jar', '0.03'])
In [ ]:
example_result
In [ ]:
type(example_result)
In [ ]:
print(example_result)
In [ ]:
result_string = str(example_result,'utf-8')
In [ ]:
type(result_string)
In [ ]:
import re
In [ ]:
re.findall(r'There are \d+ different connected components for cutoff \d+.\d+', result_string)
In [ ]:
example_result = None # wipe out pre-existing if exists
example_result = subprocess.check_output(['java', '-jar', '../ConstructBinaryNetwork.jar', '0.03'])
In [ ]:
example_result
In [ ]:
def connected_components(cutoff = 0.03):
print('find connected components for edges with magnitude greater than {}'.format(cutoff))
example_result = subprocess.check_output(
['java', '-jar', '../ConnectedComponents.jar', str(cutoff)])
results = str(example_result,'utf-8')
result_sentence = re.findall(r'There are \d+ different connected '
'components for cutoff \d+.\d+', results)[0]
print(result_sentence)
cc = re.findall('(\d+) different', result_sentence)
cutoff = re.findall('for cutoff (\d+.\d+)', result_sentence)
return {'cutoff': cutoff, 'connected components':cc}
In [ ]:
connected_components()
In [ ]:
connected_components(0.05)
In [ ]:
results = pd.DataFrame()
#import pdb; pdb.set_trace()
for i in [0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07]:
#result = pd.DataFrame({'connected components': ['6'], 'cutoff': [i]})
#print(result)
result = pd.DataFrame(connected_components(i))
results = pd.concat([results, result], axis=0)
print(results)
In [ ]:
results
In [ ]: