Friday, August 5, 2016

Data File Entries into Empty Lists

Hello All,

I have what I hope will be a simple question.
I have a text file that has a list of sample names, one per line as below:

STX2
XXX3
DXM4
etc....

I can read the file into a list:

file = open(str(filepath) + '/SampleNames.txt')
lines = file.readlines()

querylist = []
linenumber = 0

for i in lines:
    linenumber = linenumber + 1
    querylist.append(lines[linenumber - 1])

   

So I now have a list : querylist['STX2n\', 'XXX3n\', 'DXM4n\', etc....]

I need to be able to convert each item in the list into a new, standalone, empty list. Something that would appear like below once finalized:

STX2 = []
XXX3 = []
DXM4 = []

Try as I might, I've been unable to come up with a simple solution.  There is surely a function or command I don't know about that will accomplish this, as it seems pretty straight forward...

Thanks in advance for any help,

Josh Peek

**********************************************************************************
EDIT:  8/12/16

I've found what appears to be a simple solution, seen below:

for item in querylist:
   exec((item) + (' = []'))


The function exec() executes string input as python code.  So as of now, I am pulling each item in the querylist[] into the exec() function as a string and executing it.  This builds each list as I wanted.  I don't know if this is proper or not, but it seems to be working well...










Monday, August 1, 2016

Friday, July 15, 2016

I am back!

(really good to be back!)

We will meet (as usual) at HudsonAlpha - 9 am - Tuesday July 19

1) Come with questions or
2) post questions/suggestions or
3) ideas or
4) - ?

Thursday, July 7, 2016

Data Filter Help

I am trying to find a script to filter through .csv files and output data that specifically matches 645 patient numbers out of 1612 total patients.

The output can be placed into a .csv file format as well.

I was able to find a number of scripts that kind of do this but not exactly.


Tuesday, June 28, 2016

Copy and paste a file from one location to another

I am trying to copy a file (that contains various contexts) from one area and paste it in another area.

I am using the cp command --> cp  /source.of.file /destination.of.file

The operator keeps responded omitting the /source.of.file  

OR

The operator responds the /source.of.file is not a directory (however when I cd to the /source.of.file it takes me right to the correct directory.

(Additional Information: I am in a node under cluster on command line.)

Saturday, June 25, 2016

Future Meetings (please note!)

I am away June 28, July 5 and July 12 ...!

But will monitor this blog and help best way I can


Wednesday, June 22, 2016

Elizabeth Andrew's code for reading molecular coordinates from a file

#!/usr/bin/python

import sys
from pybel import *


mol = readfile("g09", "stauranthine_GC_dimer_xyz_1.out").next()

atomtotal = 0
for mol in readfile("g09", "stauranthine_GC_dimer_xyz_1.out"):
atomtotal += len(mol.atoms)


atom_number = { 1 : 'H',
6 : 'C',
7 : 'N',
8 : 'O'
}

for atom in mol:

x = atom.coords[0]
y = atom.coords[1]
z = atom.coords[2]
print atom_number[atom.atomicnum]+'\t'+str(x)+'\t'+str(y)+'\t'+str(z)

#I am having trouble getting the xyz coordinates to form right aligned even columns. Some of the coordinates have negative signs which causes the misalignment.