I have been trying to automate the renumbering of pdb-files using a numbering server called Abnum. They state: To number a structure you must pass parameters in POST format and use enctype="multipart/form-data". It does work for a single sequence, but uploading the pdb-file(plain-text file) remains a problem.
My code:
import requests
rel_path = "PDB_mono"
rel_path2 = "1A5F.pdb"
i = os.path.abspath(__file__)
g = os.getcwd()
mypath = os.path.join(g,rel_path)
mypath = os.path.join(mypath,rel_path2)
print mypath
url = 'http://www.bioinf.org.uk/cgi-bin/abnum/abnumpdb.pl?plain=1&pdb=1A5F.pdb&scheme=-a&output=-l'
files = {'file': open('1A5F.pdb', 'rb')}
r=requests.post(url, files={'file': open(mypath)}).content
print r
Myfile:
mypath =F:\Leuven\Python\PDB_mono\1A5F.pdb
Response:
<html>
<head>
<title>AbNum results</title>
<link rel='stylesheet' href='/bo.css' />
</head>
<body>
<h1>Abnum: PDB numbering</h1>
<h3>There was an error in your submission</h3>
<pre>
Either the PDB file you specified did not exist, or contained no ATOM records
</pre>
<p>Click the browser "Back" button to return to the form and correct your error.</p>
</body>
</html>
</body>
</html>
I'm using Windows 7, python 2.7.
I would really appreciate a response, or at least some pointing in the right direction
example PDB file:
pdb file
You can download it on the right as a text file. It's a simple file containing coordinates of atoms
Related
I'm using Rails 5.1.4 with the code below. I have confirmed that the material.js file is being processed and the material-components-web module is downloaded and discovered.
Why is mdc undefined when calling window.mdc.autoInit()?
// app/javascript/packs/material.js
import 'material-components-web'
// app/views/layouts/application.html.eeb
<html>
<head>
<%= javascript_pack_tag 'material' %>
</head>
<body>
<script>window.mdc.autoInit();</script>
</body>
</html>
I have tried
importing #material/auto-init separately.
Putting the autoInit call inside an onload
Adding a console.dir(window)/console.dir(this) inside pack file. this is not window inside the the pack file and the exports aren't being attached to this
To make material-components-web work with Rails I did
// app/javascript/packs/material.js
import * as mdc from 'material-components-web'
// for accessing it as a window object
window.mdc = mdc
And then I made sure window.mdc.autoInit() was called at the end of the body
I use following code to parse html template. It works well.
func test(w http.ResponseWriter, req *http.Request) {
data := struct {A int B int }{A: 2, B: 3}
t := template.New("test.html").Funcs(template.FuncMap{"add": add})
t, err := t.ParseFiles("test.html")
if err!=nil{
log.Println(err)
}
t.Execute(w, data)
}
func add(a, b int) int {
return a + b
}
and html template test.html.
<html>
<head>
<title></title>
</head>
<body>
<input type="text" value="{{add .A .B}}">
</body>
</html>
But when I move html file to another directory. Then use the following code. The output is always empty.
t := template.New("./templates/test.html").Funcs(template.FuncMap{"add": add})
t, err := t.ParseFiles("./templates/test.html")
Can anyone tell me what's wrong? Or html/template package can not be used like this?
What's wrong is that your program (the html/template package) can't find the test.html file. When you specify relative paths (yours are relative), they are resolved to the current working directory.
You have to make sure the html files/templates are in the right place. If you start your app with go run ... for example, relative paths are resolved to the folder you're in, that will be the working directory.
This relative path: "./templates/test.html" will try to parse the file being in the templates subfolder of the current folder. Make sure it's there.
Another option is to use absolute paths.
And also another important note: Do not parse templates in your handler function! That runs to serve each incoming request. Instead parse them in the package init() functions once.
More details on this:
It takes too much time when using "template" package to generate a dynamic web page to client in golang
I'm developing a ruby on rails application, and would simply like there to be a button on one of my tables' show.html.erb pages that plays a single audio file. The html.erb file below will do all of this flawlessly when it's opened manually in firefox, but not when it gets called by my rails server. Instead there is no autoplay, and the button shows up but does nothing when you click it.
<!DOCTYPE html>
<html>
<head>
</head>
<button onclick="playAud()" type="button">Play</button>
<audio id = "audio" autoplay>
<source src= 'my audio.mp3' type="audio/mpeg">
</audio>
<script>
var audio = document.getElementById("audio");
function playAud() {
audio.play();
}
</script>
</body>
</html>
Also, when I add the controls command to the html audio tag, I sometimes see the controls flash briefly on the screen then disappear.
In my final html.erb I will be using a lot of controller-created variables and such, but right now I'm just trying to get this simple issue resolved. My controller's show method is all commented out at the moment.
How can I get this audio button to work?
When I go to the rails server on the console, I see this at the end of the list of actions performed:
Started GET "/phrases/my%20audio.mp3" for 127.0.0.1 at 2015-03-24
17:29:21 -0600 Processing by PhrasesController#show as
Parameters: {"id"=>"my audio"} Rendered phrases/show.html.erb within
layouts/application (0.9ms)
So it looks like the server is recognizing 'my audio.mp3' as a parameter it needs to "GET" for some reason... no idea why it would do that.
Figured it out! I haven't been using the only default asset folder (still don't know how to add more, but I'll figure it out eventually), which is (duh) the "public" folder. When I placed my audio in the public folder and changed the source of the audio to '/my audio.mp3', it worked!
<audio autoplay>
<source src='/my audio.mp3' type="audio/mpeg">
</audio>
I'm so glad that's over... so painful!
Your code works fine if you put your media file into same dir as your html then update code to find it as
<source src= 'your_audio.mp3' type="audio/mpeg">
Avoid full path to a location outside visability of a web server (security restrictions prevent web server from seeing files in arbitrary locations) ... once working identify more appropriate media dir as defined by web server config
I am using TCPDF library to generate some reports, and i want to send the PDF file to print option of browser as simple we press CTRL+P, I need this because it is slip.
I used all parameter for Output but it is downloading the file directly.
$pdf->Output('slip.pdf', 'I');
I also placed the F,D,S,E,FI and FD instate of I but it doesn't work. And I also used header
header('Content-Type: application/pdf');
$pdf->Output('example_001.pdf', 'FD');
but again it doesn't work. Any solution? Please!
Add
$pdf->IncludeJS("print();");
just before $pdf->Output...
You need something like the example below. You would need to intercept print request (print automatically on page load, print button click, etc.) and then call printTrigger function.
<html>
<head>
<title>Print PDF</title>
<script>
function printTrigger(elementId) {
var getMyFrame = document.getElementById(elementId);
getMyFrame.focus();
getMyFrame.contentWindow.print();
}
</script>
</head>
<body>
<iframe id="iFramePdf" src="http://pdfurl.com/sample.pdf"></iframe>
...
</body>
</html>
What you are trying to do is not within the specification of the TCPDF API.
http://www.tcpdf.org/doc/code/classTCPDF.html#a3d6dcb62298ec9d42e9125ee2f5b23a1
I believe you would need to use JavaScript to implement this feature the way you are proposing.
Add $pdf->IncludeJS("print();"); just before $pdf->Output...
It's working for me.
Trying to setup a test page that access a video hosted on S3 and streamed using CloudFront. The player I'm using is JWPlayer, which is supposed to work with iOS devices as well.
Unfortunately, nothing happens when I open it on the iPhone... I'm sure the answer is obvious, but it has eluded me for the last hour. Here's the code (mostly a copy/paste from http://aws.amazon.com/articles/4101?_encoding=UTF8&jiveRedirect=1):
<!-- THIS IS A BASIC HTML FILE TO PLAY MP4's USING JW PLAYER
The following code is from longtailvideo.com's 'Setup Wizard', found at http://www.longtailvideo.com/support/jw-player-setup-wizard -->
<HTML>
<HEAD>
<TITLE>
Streaming Video with JW Player
</TITLE>
</HEAD>
<BODY>
<!-- Put a header above your video, if you like
-->
<H1>This is my header</H1>
<script type='text/javascript' src='http://s3.amazonaws.com/intrinseque-video/swfobject.js'></script>
<div id='mediaspace'>This text will be replaced</div>
<script type='text/javascript'>
var so = new SWFObject('http://s3.amazonaws.com/intrinseque-video/player.swf','mpl','470','290','9');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','opaque');
so.addVariable('file','mp4:oceans-clip.ipad.mp4');
so.addVariable('streamer','rtmp://s1m21pqfl8vlrl.cloudfront.net/cfx/st/');
so.write('mediaspace');
</script>
</BODY>
</HTML>
<!--Common problems:
- You cannot have any spaces in any of your URL's (including your 'rtmp://...' URL) (i.e., http:// thereisaspaceatthebeginninghere.xxx)
- Be sure you are calling the correctly numbered version of the flowplayer objects/players (i.e. flowplayer-3.2.2.swf
- You cannot have duplicates of 's3.amazonaws.com' or 'cloudfront.net' in the same address (i.e. (http://s3.amazonaws.com/s3.amazonaws.com/YOUR_BUCKET/player.swf)
- There is a different naming protocol for mp4 vs flv files. For .mp4 files, YOU MUST write it as 'mp4:YOUR_VIDEO_FILE_WITHOUT_THE _MP4_SUFFIX'. For .flv files, you simply write the name of the file, 'YOUR_VIDEO_FILE_WITHOUT_THE_FLV_SUFFIX'.
-->
Check out http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/49/using-cloudfront
You need to add something along the lines of:
modes: [{
type: "flash",
src: "/assets/player.swf"
},{
type: "html5"
config: {
file: "http://dXXXXXXXXXXXX.cloudfront.net/example.mp4"
provider: "video"
}
}],
to the code for it to handle correctly both flash and html5.
Actually, not all mp4 files are born equal. Ones converted with weird encoders/codecs sometimes don't work on IOS. I had a case where, handbreak encoded mp4 didn't play, while ffmpeg encoded same video streamed perfectly.
I never understood what exactly was the difference. Maybe something to do where you place video metadata insdie the file.