Skip to content

Instantly share code, notes, and snippets.

@indapa
Created March 8, 2013 02:47
Show Gist options
  • Save indapa/5113856 to your computer and use it in GitHub Desktop.
Save indapa/5113856 to your computer and use it in GitHub Desktop.
Using dtype object and loadtxt command to read file contents into a Numpy array
#simref.1 653 T TT GT TT
#simref.1 1216 T CC CC CC
#simref.1 1440 A AA AG AA
#simref.1 1470 A CC CC CC
#simref.1 2070 C AA AA AA
#simref.1 2489 C GG GG GG
import numpy as np
dt = np.dtype( [ ('chrom', 'S8'), ('pos', 'int32'), ('ref','S1'), ('father','S2'), ('mother','S2'), ('child','S2')] )
pgm_array=np.loadtxt(file,delimiter='\t',dtype=dt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment