Skip to content

Instantly share code, notes, and snippets.

View macperez's full-sized avatar

Manuel Antonio Castro Pérez macperez

View GitHub Profile
@macperez
macperez / factors.py
Last active September 11, 2025 10:04
Obtiene la descomposición en factores primos
def find_factors_v1(value:int) -> list:
factors = []
count = 0
div = 2
while value > 1:
if value % div:
div += 1
else:
factors.append(div)
value /= div
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 13 in line 1.
Paper|Ecoregion|BIOME|Type_of_Species|Species|WU|MUWM|CARN|DOM|HARE|SM|BIRD|REPT|FISH|ARTHR|PLANTS|OTHER|WASTE|Percentage
1971_Bothma|548|10|3|SF|0,62||0,00|0,00|3,11|24,84|7,45|0,62||14,91|19,88|13,04|15,53|100,00
1971_Bothma|548|10|1|SSJ|6,67|||3,33||3,33|10,00|13,33||13,33|26,67|23,33||100,00
1971_Bothma|548|10|4|Viverra_civeta|2,17|||||6,52|8,70|4,35||21,74|28,26|21,74|6,52|100,00
1977_Stuart|1110|9|2|WC||||||46,41|5,64|0,09||41,19|6,68|||100,00
1978_Delibes|86|2|4|Mart|||||2,84|26,48|11,08|2,27|1,42|21,31|32,48|2,27||100,15
1978_Fritts|201|8|2|BC|12,57|1,05|7,85|1,05|30,37|34,03|6,28|1,05||||5,76||100,00
1978_Lamprecht|512|3|1|AGW|2,28|15,98||||10,05|1,37|0,00||45,66|23,29||1,37|100,00
1981_Stuart|1008|4|3|BEF||||||2,18|0,87|0,87||82,97|11,79|1,31||100,00
1981_Stuart|1008|4|3|CF||||10,26||16,67|5,13|5,13||46,15|10,26|6,41||100,00
@macperez
macperez / histogram_dna_sam.py
Created May 30, 2018 16:47
Creating an histogram of DNA sequence lengths from SAM files.
import os
import csv
import pandas as pd
SAM_FILES_PATH = 'sam/'
RESULT = {}
def process_sam(filename, header_values):
df = pd.read_table(SAM_FILES_PATH + filename, sep='\t', skiprows=[0, 1], names=list('abcdefghijkl'))