- Upvotes Received
- 0
- Posts with Upvotes
- 0
- Upvoting Members
- 0
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
If I have a list of strings, for example here's a small part of my list: [CODE]small_list=['HETATM 2142 O DUM 2142 -26.000 -8.000 12.300','HETATM 2143 O DUM 2143 -26.000 -6.000 12.300'][/CODE] Is there a way to remove the 12.300 from a string in this list and then replace it with … |
|
I was wondering if there was a difference between Python and ActivePython. Is there an advantage to using one over another? |
|
I keep getting this error: error: unable to find vcvarsall.bat What is vcvarsall.batand why do I need it? I'm new to programming. Please explain as simply as possible!! Thanks! |
|
I have this code: [CODE]protein="GWEIQPYVWDECYRVFYEQLNEEHKKIFKGIFDCIRDNSAPNLATLVRVTTNHFTHEQAMMDAVKFSEVLPHKKMHRDFLEKLGGLSAPVDNHIKGTDFKYKGKAKNVDYCKEWLVL" pp="LLCCCCCCCCCCCCCCCCCCHHHHHHHHHHHHHHHHHCHHHHHHHHHHHHHHCCCCHHHHHHHCLLLCCCCCHHHHHHHHHHHHHHHHHHHCCCCCCCCCCCHHHHHHHHHHHHCCL" gor="cccccccccccchhhhhhhhhhhhhhhhhhhhhhhccccccccceeeeecccccchhhhhhhhhhhcccchhhhhhhhhhhhhccccccccccccccccccccccceeceeccceec" aber="CCCCCCCCCCCCHHHHHHHCCHHHCHHHHHHHHHHCCCCHHHHHHHHHHHCCCCCCHHHHHHHCCCCCCCHCCHHHHHHHHHHCCCCCCCCCCCCCCCCCCCCCCCCCHHHHHHHCC" for i in range(len(protein)): print i+1,protein[i], pp[i], gor[i], aber[i] [/CODE] I'm trying to compare these strings. However, the output is in a vertical format. How can I print it so that the format is vertical? This would make it much easier to … |
|
I'm writing a code to minimize a function and I'm having problems storing the new move. [CODE]import math import random #minimze the function: def f(x): return math.pow(x,2) + math.sin(10*x) x_list=[] energy_list=[] g=2 #starting position def move(): #Generate a random move random.uniform(-0.5,0.5) def energy(): h=g+move() #generate random move E = f(g)-f(h) … |
|
[ICODE]import random import itertools def test(number): return random.random()*number [/ICODE] Say I have a function and I want to repeat it x times so that I may calculate the standard deviation. How can I do this? I've tried using itertools.repeat(test(5),3) but it prints repeat(value,3) which I can't calculate the standard deviation. … |
|
So I have this list of strings. They all of the strings have a 18 capital letters. I want to assign each letter a value and them sum up the total score. [CODE]window=['SALHWRAAGAATVLLVIVL', 'ALHWRAAGAATVLLVIVLL', 'LHWRAAGAATVLLVIVLLA', 'HWRAAGAATVLLVIVLLAG', 'WRAAGAATVLLVIVLLAGS', 'RAAGAATVLLVIVLLAGSY', 'AAGAATVLLVIVLLAGSYL', 'AGAATVLLVIVLLAGSYLA', 'GAATVLLVIVLLAGSYLAV', 'AATVLLVIVLLAGSYLAVL', 'ATVLLVIVLLAGSYLAVLA', 'TVLLVIVLLAGSYLAVLAE', 'VLLVIVLLAGSYLAVLAER', 'LLVIVLLAGSYLAVLAERG', 'LVIVLLAGSYLAVLAERGA', 'VIVLLAGSYLAVLAERGAP', 'IVLLAGSYLAVLAERGAPG', 'VLLAGSYLAVLAERGAPGA', … |
|
Hi. I was wondering if anyone knows how to establish x,y,z coordinates in python. I want to be able to extract this data from a text file. Here are sample lines in my text file: [CODE] ATOM 1 N GLN A 4 62.131 49.287 59.621 1.00 67.10 N ATOM 2 … |
|
Hi, I want to change an item from one value to another. How would I do this? |
|
Say I have two lists: list1=[a,b,c,d,e,f,a,b,c] list2=[a,c,d] How could I compare list1 and list2 such that I would get an output like: list3=[match,-,match,match,-,-,-,-,-] So that it goes in order Here's my code: [CODE]h=[] for i in range(len(change2)): for j in range(len(atom)): if atom[j]==atom[i]: h.append("H") else: h.append("-") print h[/CODE] Both change2 … |
|
Hi, I want to change an item from one value to another. How would I do this? |
|
I am having problems with tuples. I have a list of tuples that have (x,y,z) coordinates. Each coordinate is a float. How can I calculate the distance between two coordinates? Can you do this with tuples? [CODE]coord=[] for line in CN_list: x=line[30:39] y=line[38:47] z=line[46:55] coord.append((float(x),float(y), float(z)))[/CODE] |
|
[CODE]for i in range(len(sumprop3)): for j in range(len(x2)): if j==i: print x2[j], atomnumber[i:i+8] [/CODE] For atomnumber[i:i+8] it is printing the range ie [1,2,3,4,5,6,7,8]. I want it to print just [1,8]. How would I do this? |
|
Is there a logical operator in python for and/or of strings? I am trying to write a weasel code. What I have so far: [CODE]import random import math keys='abcdefghijklmnopqrstuvwxyz ' monkey='methinks it is like a weasel' def attempt(): attempt='' for i in range(len(monkey)): x=random.choice(keys) attempt+=x return(attempt) library_attempts=[] for i in … |
|
Hi there. I am trying write a module that can be executed at the command line and for some reason it's not working. Does anyone know why? [CODE]import sys def fibonacci(N): a,b =0,1 while b < N: a,b = b, a+b print b N=sys.argv[1][/CODE] Does it matter that I'm running … |
|
for: [CODE]import random keys='abcdefghijklmnopqrstuvwxyz ' random.choice(keys)[/CODE] How would I count how many times it takes random.choices(keys) to generate "m"? |
|
[CODE]import math import random choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,\ 37, 38, 39, 40, 41, 42, 43, 44, 45, … |
|
This might be dumb... but I'm having problems raising e to a negative number and I can't figure out what is going on. [CODE]>>> math.exp(((-23*(23-1))/730)) 0.36787944117144233 >>> math.exp(-506/730) 0.36787944117144233 >>> math.exp(-.69) 0.5015760690660556 >>> math.exp(-(506/730)) 1.0[/CODE] For some reason I keep getting different answers when they should all be the same... … |
|
Hi I am VERY new to python. I am trying to write a function that returns lines from a text file to a new file. I can't seem to get it right. So far my code looks like this: [CODE]def seperate_atoms(f):#Enter .pdb file in with quotations myfile=open(f,'r') crudepdb=myfile.readlines() cleanpdb=[] for … |