Re: comapring 2 sequences of DNA ouput the silent and non mutations
2016-10-29 21:38 GMT+02:00 : > > Code: > > [...] > > for i in range (len(protein) & len(seq1)) : > > if protein[i] != mutantPRO[i] : >print (protein[i] + str(i) + mutantPRO[i]) >A+= 1 > else: > if seq1[i:i+3] != mutant[i:i+3]: > print(protein[i] + str(i) + mutantPRO[i] +' Silent mutation ') > print(seq1[i:i+3] + mutant[i:i+3]) > B+= 1 Hi, The problem here is that you try to mix two different index in one variable. Instead, you need to do something like this: #i index protein #j index DNA for i in range (len(protein)) : j = i*3 if protein[i] != mutantPRO[i] : print (protein[i] + str(i) + mutantPRO[i]) A+= 1 else: if seq1[j:j+3] != mutant[j:j+3]: print(protein[i] + str(i) + mutantPRO[i] +' Silent mutation ') print(seq1[j:j+3] + mutant[j:j+3]) B+=1 -- https://mail.python.org/mailman/listinfo/python-list
pip3 : command not found
Hi, So I wads trying to install some packages for python3. when I run pip3 in terminal i receive the error "pip3 : command not found". When looking at the path, I noticed /usr/local/Cellar/python3/3.5.2_3 does not have pip3 in the directory while /usr/local/Cellar/python3/3.5.2_2 does have. I am guessing this is the issue. I tried using the get-pip.py and that didnt work either. When I search for pip I find pip, pip2 and pip2.7 all of which are for python 2.7. I tried uninstalling python3 and reinstalling but that didnt work either. I am running this on Mac OS Sierra. Please let me know how I can fix this. Looking forward to your response. Regards, Vishal Subbiah Institute for Computational and Mathematical Engineering Masters Student Stanford University -- https://mail.python.org/mailman/listinfo/python-list
Re: pip3 : command not found
Vishal Subbiah writes: > So I wads trying to install some packages for python3. when I run pip3 > in terminal There is no guarantee that a command named ‘pip3’ will be installed. Instead, you should invoke the exact Python interpreter you want – and, by extension, the Python environment into which you want packages installed. $ /foo/bar/virtualenv/bin/python3 -m pip install LoremIpsum If you already have a specific environment active and know that ‘python3’ is the correct Python interpreter from that environment, you can omit the explicit path. $ python3 -m pip install LoremIpsum Why doesn't a command ‘pip’ or ‘pip3’ do the job? Because there's no guarantee that will use the specific Python environment you want. For many programs, it simply doesn't matter which Python interpreter – or even *whether* a Python interpreter or Perl interpreter or etc. – is the one that runs. So most Python-implemented programs you don't need to specify which interpreter; they know how to find it themselves, and your choice of a different environment should not affect their operation. But for a command that has the primary purpose of interacting with that environment – by installing or removing packages, as Pip does – it must obey your explicit instruction on which Python environment and interpreter to use. -- \ “It ain't so much the things we don't know that get us in | `\trouble. It's the things we know that ain't so.” —Artemus Ward | _o__) (1834–1867), U.S. journalist | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: pip3 : command not found
Hi, Thanks Ben for the response. I followed your suggestion and this is what i get: "python3 -m pip3 install LoremIpsum /usr/local/opt/python3/bin/python3.5: No module named pip3" "python3 -m pip install LoremIpsum /usr/local/opt/python3/bin/python3.5: No module named pip" How do I fix this? Regards, Vishal Subbiah Institute for Computational and Mathematical Engineering Masters Student Stanford University On Sun, Oct 30, 2016 at 5:37 PM, Ben Finney wrote: > Vishal Subbiah writes: > > > So I wads trying to install some packages for python3. when I run pip3 > > in terminal > > There is no guarantee that a command named ‘pip3’ will be installed. > > Instead, you should invoke the exact Python interpreter you want – and, > by extension, the Python environment into which you want packages > installed. > > $ /foo/bar/virtualenv/bin/python3 -m pip install LoremIpsum > > If you already have a specific environment active and know that > ‘python3’ is the correct Python interpreter from that environment, you > can omit the explicit path. > > $ python3 -m pip install LoremIpsum > > > > Why doesn't a command ‘pip’ or ‘pip3’ do the job? Because there's no > guarantee that will use the specific Python environment you want. > > For many programs, it simply doesn't matter which Python interpreter – > or even *whether* a Python interpreter or Perl interpreter or etc. – is > the one that runs. > > So most Python-implemented programs you don't need to specify which > interpreter; they know how to find it themselves, and your choice of a > different environment should not affect their operation. > > But for a command that has the primary purpose of interacting with that > environment – by installing or removing packages, as Pip does – it must > obey your explicit instruction on which Python environment and > interpreter to use. > > -- > \ “It ain't so much the things we don't know that get us in | > `\trouble. It's the things we know that ain't so.” —Artemus Ward | > _o__) (1834–1867), U.S. journalist | > Ben Finney > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: pip3 : command not found
On Mon, Oct 31, 2016 at 12:15 PM, Vishal Subbiah wrote: > "python3 -m pip install LoremIpsum > /usr/local/opt/python3/bin/python3.5: No module named pip" > > How do I fix this? This is the one that ought to work. Something's gone wrong with the installation; as part of the install of recent Pythons, ensurepip should be run, which will provide you with pip. How did you install Python? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: pip3 : command not found
Vishal Subbiah writes: > Hi, (Please don't top-post in responses. Instead, post your responses interleaved with only the quoted material you are responding to https://en.wikipedia.org/wiki/Posting_style#Interleaved_style>.) > Thanks Ben for the response. I followed your suggestion and this is > what i get: > > "python3 -m pip3 install LoremIpsum > /usr/local/opt/python3/bin/python3.5: No module named pip3" Do you know of anything which should provide a module named ‘pip3’? I don't know of any distribution which makes such a module available for import, so unless you know it's available you shouldn't expect it. > "python3 -m pip install LoremIpsum > /usr/local/opt/python3/bin/python3.5: No module named pip" > > How do I fix this? You have revealed that the Python 3 interpreter at that path does not have a ‘pip’ module. That's a problem, but should be easily solved https://docs.python.org/3/library/ensurepip.html>. -- \ “Creativity can be a social contribution, but only in so far as | `\ society is free to use the results.” —Richard M. Stallman | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: pip3 : command not found
> How do I fix this? Maybe: $ brew uninstall python3 $ brew install python3 -- https://mail.python.org/mailman/listinfo/python-list
Calling Bash Command From Python
Python 2.7.9 on Linux Here is a bash command that I want to run from a python program: sudo grep "^user\:" /etc/shadow If I enter the command directly into a terminal it works perfectly. If I run it from a python program it returns an empty string. Below is the code I am using. Suggestions appreciated. cmdlist = ["sudo", "grep", '"^$USER\:"', "/etc/shadow"] p = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE) shadow, err = p.communicate() print shadow -- GNU/Linux user #557453 -- https://mail.python.org/mailman/listinfo/python-list
Re: Calling Bash Command From Python
On Mon, Oct 31, 2016 at 3:19 PM, Wildman via Python-list wrote: > Here is a bash command that I want to run from a python > program: sudo grep "^user\:" /etc/shadow > > If I enter the command directly into a terminal it works > perfectly. If I run it from a python program it returns an > empty string. Below is the code I am using. Suggestions > appreciated. > > cmdlist = ["sudo", "grep", '"^$USER\:"', "/etc/shadow"] > p = subprocess.Popen(cmdlist, > stdout=subprocess.PIPE, > stderr=subprocess.PIPE) > shadow, err = p.communicate() > print shadow Are you able to run that command without a password? sudo might be attempting to open the console, failing, and aborting the command. Is anything being printed to stderr? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Call a shell command from Python (was: Calling Bash Command From Python)
Wildman via Python-list writes: > Python 2.7.9 on Linux > > Here is a bash command that I want to run from a python > program: sudo grep "^user\:" /etc/shadow Some points to note: * Those commands are not special to Bash, or any particular shell. They invoke commands, without AFAIK any specific Bash features. So this is asking rather to invoke a shell command. Nothing wrong with that; but on that basis, I've changed the subject field. * You're asking to invoke the ‘sudo’ command, which itself is designed to switch to a separate user identity and run another program. * The above command is (I assume) typed into a shell, but your Python program never invokes Bash or any other shell. > If I enter the command directly into a terminal it works perfectly. Note that ‘sudo’ is specifically designed to be invoked interactively, seeking to verify that the current user has credentials to run the command. Note further that ‘sudo’ will record when the *current user session* last invoked ‘sudo’ and seek re-verification if that is too long in the past. Both of these are security measures, and are designed to avoid non-interactive use of ‘sudo’. Rather, it's meant to be used interactively by a real, present human with credentials to run the command. > If I run it from a python program it returns an empty string. You can also check the exit status of a command; ‘grep’ will give different exit status for a match versus no match. > Below is the code I am using. Suggestions > appreciated. > > cmdlist = ["sudo", "grep", '"^$USER\:"', "/etc/shadow"] One immediate difference I see is that you specify different arguments to ‘grep’. You have a different pattern for each command. * The ‘^user\:’ pattern matches “user\:” at the start of a line. * The ‘^$USER\:’ pattern I think won't match anything, since “$” matches end-of-line and then you expect further characters *past* the end of the line. I think that will always fail to match any line. > p = subprocess.Popen(cmdlist, > stdout=subprocess.PIPE, > stderr=subprocess.PIPE) > shadow, err = p.communicate() Maybe you are expecting Bash to be involved somehow (and so “$USER” will be substituted by Bash with some other value). That's not what happens. Instead, the ‘subprocess.Popen.communicate’ method will invoke the program directly, without involving a shell. See the documentation for ‘subprocess.Popen’. -- \“If you continue running Windows, your system may become | `\unstable.” —Microsoft, Windows 95 bluescreen error message | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Call a shell command from Python (was: Calling Bash Command From Python)
On Mon, Oct 31, 2016 at 3:44 PM, Ben Finney wrote: > Note that ‘sudo’ is specifically designed to be invoked interactively, > seeking to verify that the current user has credentials to run the > command. > > Note further that ‘sudo’ will record when the *current user session* > last invoked ‘sudo’ and seek re-verification if that is too long in the > past. > > Both of these are security measures, and are designed to avoid > non-interactive use of ‘sudo’. Rather, it's meant to be used > interactively by a real, present human with credentials to run the > command. I don't know that non-interactive sudo is so bad a thing. In fact, sudo has a --non-interactive option that appears specifically designed for this kind of thing - it causes the command to fail rather than prompt. You can configure a sudoers file to allow passwordless execution of specific commands, and then permit scripts to elevate privileges in very limited ways, safely. ChrisA -- https://mail.python.org/mailman/listinfo/python-list