Skip to content

Instantly share code, notes, and snippets.

@pristanna
Last active February 10, 2020 13:43
Show Gist options
  • Save pristanna/d947a29a00292e1938c2e06e47aa47fd to your computer and use it in GitHub Desktop.
Save pristanna/d947a29a00292e1938c2e06e47aa47fd to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 6 16:40:54 2020
@author: Pedazo
"""
from sys import argv
import pandas as pd
#file_path = 'd947a29a00292e1938c2e06e47aa47fd-f37020538a4ea7acb3f679b6ca1a1e14e69d4ac9/x505952.MUC1_12345.1-122x.6789.sorted.filtered.idxstats'
input_path, output_path = argv[1:]
df_list = []
for line in open(input_path):
df_list += [line.strip().split()]
df = pd.DataFrame(df_list)
df.columns = ['reference','length', 'coverage', 'something']
df.coverage = pd.to_numeric(df.coverage)
max_coverage = df.coverage == df.coverage.max()
beginning = list(df.index[max_coverage].values)[0]
df.iloc[beginning-3:,].to_csv(path_or_buf=output_path, sep='\t', index=False, header=False)
12345.1x.6789 600 2 0
12345.2x.6789 660 1 0
12345.3x.6789 720 4 0
12345.4x.6789 780 2 0
12345.5x.6789 840 4 0
12345.6x.6789 900 6 0
12345.7x.6789 960 1 0
12345.8x.6789 1020 2 0
12345.9x.6789 1080 10 0
12345.10x.6789 1140 6 0
12345.11x.6789 1200 5 0
12345.12x.6789 1260 6 0
12345.13x.6789 1320 10 0
12345.14x.6789 1380 5 0
12345.15x.6789 1440 4 0
12345.16x.6789 1500 7 0
12345.17x.6789 1560 6 0
12345.18x.6789 1620 8 0
12345.19x.6789 1680 9 0
12345.20x.6789 1740 9 0
12345.21x.6789 1800 14 0
12345.22x.6789 1860 9 0
12345.23x.6789 1920 7 0
12345.24x.6789 1980 12 0
12345.25x.6789 2040 6 0
12345.26x.6789 2100 9 0
12345.27x.6789 2160 15 0
12345.28x.6789 2220 11 0
12345.29x.6789 2280 8 0
12345.30x.6789 2340 4 0
12345.31x.6789 2400 8 0
12345.32x.6789 2460 20 0
12345.33x.6789 2520 3 0
12345.34x.6789 2580 28 0
12345.35x.6789 2640 2936 0
12345.36x.6789 2700 150 0
12345.37x.6789 2760 3 0
12345.38x.6789 2820 1 0
12345.39x.6789 2880 1 0
12345.40x.6789 2940 2 0
12345.41x.6789 3000 5 0
12345.42x.6789 3060 4 0
12345.43x.6789 3120 1 0
12345.44x.6789 3180 0 0
12345.45x.6789 3240 0 0
12345.46x.6789 3300 4 0
12345.47x.6789 3360 1 0
12345.48x.6789 3420 1 0
12345.49x.6789 3480 0 0
12345.50x.6789 3540 1 0
12345.51x.6789 3600 1 0
12345.52x.6789 3660 0 0
12345.53x.6789 3720 1 0
12345.54x.6789 3780 0 0
12345.55x.6789 3840 1 0
12345.56x.6789 3900 0 0
12345.57x.6789 3960 1 0
12345.58x.6789 4020 0 0
12345.59x.6789 4080 1 0
12345.60x.6789 4140 1 0
12345.61x.6789 4200 0 0
12345.62x.6789 4260 0 0
12345.63x.6789 4320 1 0
12345.64x.6789 4380 0 0
12345.65x.6789 4440 1 0
12345.66x.6789 4500 1 0
12345.67x.6789 4560 0 0
12345.68x.6789 4620 1 0
12345.69x.6789 4680 0 0
12345.70x.6789 4740 55 0
12345.71x.6789 4800 11 0
12345.72x.6789 4860 0 0
12345.73x.6789 4920 0 0
12345.74x.6789 4980 0 0
12345.75x.6789 5040 0 0
12345.76x.6789 5100 0 0
12345.77x.6789 5160 0 0
12345.78x.6789 5220 0 0
12345.79x.6789 5280 0 0
12345.80x.6789 5340 0 0
12345.81x.6789 5400 0 0
12345.82x.6789 5460 0 0
12345.83x.6789 5520 0 0
12345.84x.6789 5580 0 0
12345.85x.6789 5640 0 0
12345.86x.6789 5700 0 0
12345.87x.6789 5760 0 0
12345.88x.6789 5820 0 0
12345.89x.6789 5880 0 0
12345.90x.6789 5940 0 0
12345.91x.6789 6000 0 0
12345.92x.6789 6060 0 0
12345.93x.6789 6120 0 0
12345.94x.6789 6180 0 0
12345.95x.6789 6240 2 0
12345.96x.6789 6300 0 0
12345.97x.6789 6360 0 0
12345.98x.6789 6420 0 0
12345.99x.6789 6480 0 0
12345.100x.6789 6540 0 0
12345.101x.6789 6600 0 0
12345.102x.6789 6660 0 0
12345.103x.6789 6720 0 0
12345.104x.6789 6780 0 0
12345.105x.6789 6840 0 0
12345.106x.6789 6900 0 0
12345.107x.6789 6960 0 0
12345.108x.6789 7020 0 0
12345.109x.6789 7080 0 0
12345.110x.6789 7140 0 0
12345.111x.6789 7200 0 0
12345.112x.6789 7260 0 0
12345.113x.6789 7320 0 0
12345.114x.6789 7380 0 0
12345.115x.6789 7440 0 0
12345.116x.6789 7500 0 0
12345.117x.6789 7560 0 0
12345.118x.6789 7620 0 0
12345.119x.6789 7680 0 0
12345.120x.6789 7740 0 0
12345.121x.6789 7800 0 0
12345.122x.6789 7860 0 0
* 0 0 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment