I wrote a code which read multiples ligand files and one receptor file and calculates the distance between XYZ coordinates of receptor and ligand files one by one. then want to write the output file for every specific ligand files separately. but my code just writing one output file and writing results for all the ligand files in one file. Below is my code:    import re   import math   import glob       class Atom:          def __init__(self, resname='', resnum='', atomid=0, chainId='',    x=0.0, y=0.0, z=0.0, atomname = '',  element = ''):     self.x=x     self.y = y     self.z = z     self.resname = resname     self.resnum = resnum     self.atomid = atomid     self.chainid = chainId     self.atomname = atomname     self.element = element     self.resnum = resnum  def __init__(self, line):     self.x = line[28: 38].strip()     self.y = line[39: 46].strip()     self.z = line[47: 56].strip()     self.resname = line[17: 21].strip()     self.resnum = line[22: 28].strip()     self.atomid = line[7: 12].strip()     self.chainid = line[22]     self.atomname = line[13: 16].strip()     self.element = line[77:78]  def caluDistence(proteinatom, ligandatoms, cutoff = 4.0):    matchedAtom = []    for atom in proteinatom:     atomX = float(atom.x)     atomY = float(atom.y)     atomZ = float(atom.z)     for hetatom in ligandatoms:         hetatomX = float(hetatom.x)         hetatomY = float(hetatom.y)         hetatomZ = float(hetatom.z)         d = math.sqrt((atomX - hetatomX)**2  + (atomY - hetatomY)**2  +   (atomZ - hetatomZ)**2 )         #print (str(d))         if d &lt;= cutoff:             if atom in matchedAtom :                 continue             matchedAtom.append(atom) return matchedAtom return d  pdb = "receptor.pdb" lig = "D:\\python\\workspace\\practise\\exhau15\\frag1\\out_ligand_*.pdbqt" files=glob.glob(lig) proteinatom=[] for line in open(pdb, 'r').readlines():    if line[0:6] == 'ATOM  ':     atom = Atom(line)     proteinatom.append(atom) ligandatoms = [] for file in files:     print("current file :" +file)     with open(file) as f:             for line in f:                 if line[0:6] == 'ATOM  ':                     atom = Atom(line)                     ligandatoms.append(atom) matchedAtomList = caluDistence(proteinatom, ligandatoms) outfile = "out2.pdb" output = open(outfile, 'w') for atom in matchedAtomList:   output.write("current file name:    " + file + "     "  + atom.resname + "     "   + atom.resnum + "        " + atom.element + '\n' )     output.flush()    output.close()
I want to write a program for this: In a folder I have n number of files; first read one file and perform some operation then store result in a separate file. Then read 2nd file, perform operation again and save result in new 2nd file. Do the same procedure for n number of files. The program reads all files one by one and stores results of each file separately. Please give examples how I can do it.
A projection satisfying $\| Px \| \leq \|x\|$ for all $x$ is an orthogonal projection How to prove that if $V$ is a finite dimensional inner product space and $W$ a subspace of $V$, if $P$ is projection map ($P^2=P$) having $W$ as its range and is such that $\|Px\| \leq \|x\|$ for all $x \in V$, then $P$ is orthogonal projection of $V$ onto $W$. How can I download an APK file from the Play Store? I can't download apps from the Play Store on my Android device (maybe due to a network issue), so I'm wondering how could I download the APK file of an app on my PC from ? Bibliography in Texmaker I'm having some problems with my bibliography in Texmaker. My code is:  \documentclass[11pt, a4paper]{article} \usepackage{graphicx} \usepackage{amsmath} \usepackage{natbib} \usepackage[utf8]{inputenc}     \usepackage{natbib} \usepackage[usenames,dvipsnames]{xcolor} \usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry} \begin{document}  ....  \cite{Johnson} \bibliographystyle{plain} \bibliography{mybib}  \end{document}   I also created a new file (File > New) that I saved as mybib.bib:  @Article{Johnson, author = {Edgar G. Johnson and Alfred O. Nier}, title = {Angular Aberrations in Sector Shaped Electromagnetic Lenses for Focusing Beams of  Charged Particles}, journal = {Physical Review}, year = {1953}, volume = {91}, number = {1}, }  @phdthesis{Zoran, author = {Zoran Racic}, title = {\'Etude et essais du spectromÃ¨tre Ã  plasma {DYMIO} de la  mission {MARS 96}}, publisher = {UniversitÃ© Pierre et Marie Curie}, year = {1996} }   When I compile my .tex file, I only have a [?] appearing.  Could you tell me what my mistake is? We are supposed to prove that the zero vector is unique with the additive identity $x+O=x$ and then by creating another additive identity with $O'$, then $x+O'=x$.  We set them equal $x+O=x+O'$ and use the vector cancelling theorem to get $O=O'$, but how does this prove that the zero vector is unique? Invalid group name: Group names must begin with a word character I received the following exception when I was using the Regex class with the regular expression: (?'named a'asdf)  System.ArgumentException: parsing \"(?'named a'asdf)\" - Invalid group name: Group names must begin with a word character.   What is the problem with my regular expression? One thing that seems to be missing in the Top&nbsp;Bar is a link to the Stack&nbsp;Exchange portal. It only displays under the "Current&nbsp;Community" section when you are in the community, but it disappears as soon as you go to another one.  Would it be possible to add a link that would always be there no matter which community you are currently on? Test for the convergence of the sequence $S_n =\frac1n \left(1 + \frac{1}{2} + \frac{1}{3} + \cdots+ \frac{1}{n}\right)$ Shadow Incorrect at Bottom of Edge How can I switch between starting a coroutine vs running the routine all at once? I have a simple question about calculating distances in PostGIS.  I would like to get the distance between two geometries. I am using this sid : 4269 in meters what i am doing now is this : ST_Distance((a.geom,b.geom)) FROM ... but I am getting result in degrees. I think that I should work with geography but how can I cast a geom to a geography? I tried with (a.geom::geography) but i am getting an error.  What can I do to get my result in meters?   Thank You What exactly is a kilogram-meter? This question isn't just about kilogram-meters, it's about multiplied units in general.  I have a good mental conception of divided units, e.g. meters per second or grams per cubic meter.  Meters per second just (usually) means how many meters are traversed by an object each second.  Simple.  But I don't really have a mental conception of what it means when units are multiplied, e.g. a kilogram-meter.  Can anyone explain in simple physical terms what a kilogram-meter is? The following code uses the etoolbox package to convert a list a,b,c into an internal list (called \mylist) and then typesets that with colons: a:b:c:.  However, when I load the etextools package (by uncommenting the second line), I get no list output.   \documentclass{minimal} \usepackage{etoolbox} %\usepackage{etextools} \begin{document} A list: \def\mylist{} \forcsvlist{\listadd\mylist}{a,b,c} \def\do#1{#1:} \dolistloop{\mylist} \end{document}   I suspect it is is a bug since etextools claims to depend on etoolbox.  Is this a bug or am I doing something wrong?  In either case, how can I use \dolistloop with  etextools (which I want for goodies like \expandnext)?  Notes   \show\mylist produces the same output a|b|c| in both cases, so the problem is with \dolistloop which expands to \forlistloop\do The \forlistloop command becomes substantially more complicated when etextools is used.  might be relevant (but not obviously). Neat series convergence result This is a nice problem on series convergence that I recently stumbled upon. Given a non-negative sequence of real numbers $(a_n)$ such that $$\sum_{n=1}^\infty a_n &lt; \infty,$$ show that there exists a non-decreasing sequence of non-negative numbers $b_n$ such that $$b_n \to \infty \quad\text{ and } \quad \sum_{n=1}^\infty a_n b_n &lt; \infty.$$ In other words, for every convergent series with non-negative terms, there is another convergent series with "substantially larger" terms.  I have a solution (see below), but maybe someone else has a different, simpler, and/or more elegant solution. Show that $\frac{1}{\sqrt{2\pi}} \cdot \left(\int_{- \infty}^{\infty} e^{itx} \cdot e^{-\frac{1}{2}t^2 } dx \right) = e^{-\frac{1}{2}t^2}$ I am struggling to show that $$\frac{1}{\sqrt{2\pi}} \cdot \left(\int_{- \infty}^{\infty} e^{itx} \cdot e^{-\frac{1}{2}x^2 } dx \right) = e^{-\frac{1}{2}t^2}$$  In the same paper we defined  $$F(t):=\left(\int_0^t e^{-x^2}\right)^2 \quad \text{ and} \quad  G(t):=\left( \int _0^1\frac{e^{-t^2(1+x^2)}}{1+x^2} \right)$$  I showed that both functions are differentiable with  $$F'= 2e^{-t^2} \cdot \int_0^t e^{-x^2}$$ $$G' = -2te^{-t^2} \cdot \int_0^1 e^{-x^2t^2}$$  It follows that $F' + G' = 0$ and $F + G = \frac{\pi}{4}$  With that I showed that $\int_{-\infty}^{\infty} e^{-x^2} = \sqrt{\pi}$.  Any help is appreciated. Deleting files older than 30 days based on filename as date If I have a folder of files with their filenames as the date they were created:  2019_04_30.txt 2019_04_15.txt 2019_04_10.txt 2019_02_20.txt 2019_01_05.txt   How would I compare the files names against todays current date  $ date "+%Y_%m_%d" &gt;&gt;&gt; 2019_04_30   If the file names date is greater than 30 days then delete it. I would expect to end up with  2019_04_30.txt 2019_04_15.txt 2019_04_10.txt   I don't have to follow this naming convention, I could use a more suitable date format. Why is it possible to get significant F statistic (p<.001) but non-significant regressor t-tests? I've been trying to prove   $$\sum_{k=1}^{n}{(-1)^{k+1} {{n}\choose{k}}\frac{1}{k}=H_n}$$  I've tried perturbation and inversion but still nothing. I've even tried expanding the sum to try and find some pattern that could relate this to the harmonic series but this just seems surreal. I can't find any logical reasoning behind this identity. I don't understand . Is there any proof that doesn't require the integral transform? Can I keep the Rueful Axe and get Clavicus Vile's Mask? Is there a way to keep the Rueful axe and get Clavicus's Mask?  I thought you could kill Barbas after receiving the mask, but he is a statue now.  Did I miss my chance? Why doesn't grep using pipe work here? How to remove the left part of a string?