In [3]:
import glob
glob.glob("/home/magnus/work-src/rna-tools/*py")
Out[3]:
In [4]:
for f in glob.glob("/home/magnus/work-src/rna-tools/*py"):
print (f)
In [5]:
def exe(cmd):
import subprocess
o = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out = o.stdout.read().strip().decode()
err = o.stderr.read().strip().decode()
return out, err
In [6]:
cmd = "ls /home/magnus/work-src/rna-tools/*py"
out, err = exe(cmd)
for f in out.split('\n'):
print f
In [11]:
cmd = "ls /home/magnus/work-src/rna-tools/*py"
out, err = exe(cmd)
import pandas as pd
df = pd.DataFrame()
for index, f in enumerate(out.split('\n')):
out, err = exe('wc -l %s' % f)
nol = out.split()[0]
df = df.append(pd.DataFrame({'fn' : f, '# of lines' : int(nol)}, index=[index]))
df
Out[11]:
In [14]:
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import pyplot, transforms
%matplotlib inline
plt.style.use('classic')
plt.rcParams['figure.facecolor']='white'
import seaborn as sns
sns.set_style("whitegrid");
plt.rcParams['axes.linewidth'] = 10;
#plt.rcParams['axes.color'] = "black"
plt.style.use('classic');
plt.rc("figure", facecolor="white");
plt.rcParams['lines.linewidth'] = 2;
import matplotlib.pyplot as plt
plt.rc('font', family='Helvetica-Normal')
In [20]:
df.plot(kind='bar')
Out[20]:
In [29]:
plt.figure(figsize=(4,4))
plt.style.use('ggplot')
ax = sns.barplot(data=df, x='fn', y="# of lines")
ax.grid()
plt.xticks(rotation=90);