Biopython PDB - finding RNA chains - biopython

I'm using Biopython's PDBParser module to read PDB files. I need to find out which models / chains belong to RNA strands. Is there any simple method for doing this?

here my attempt using pdb file [1b7f.pdb][1] from RCS_PDB repo
https://www.rcsb.org/structure/1B7F :
from Bio.PDB import PDBParser
parser=PDBParser(QUIET=True)
structure_1 = parser.get_structure('test', '1b7f.pdb')
pippo = [' A',' C',' G',' U',' I']
for model in structure_1:
for chain in model:
for residue in chain:
if residue.get_resname() in pippo:
print("'"+residue.get_resname()+"'", ' ---> model : ', model , ' chain : ', chain)
output :
' G' ---> model : <Model id=0> chain : <Chain id=P>
' U' ---> model : <Model id=0> chain : <Chain id=P>
' U' ---> model : <Model id=0> chain : <Chain id=P>
' G' ---> model : <Model id=0> chain : <Chain id=P>
' U' ---> model : <Model id=0> chain : <Chain id=P>
' U' ---> model : <Model id=0> chain : <Chain id=P>
' U' ---> model : <Model id=0> chain : <Chain id=P>
' U' ---> model : <Model id=0> chain : <Chain id=P>
' U' ---> model : <Model id=0> chain : <Chain id=P>
' U' ---> model : <Model id=0> chain : <Chain id=P>
' U' ---> model : <Model id=0> chain : <Chain id=P>
' U' ---> model : <Model id=0> chain : <Chain id=P>
' G' ---> model : <Model id=0> chain : <Chain id=Q>
' U' ---> model : <Model id=0> chain : <Chain id=Q>
' U' ---> model : <Model id=0> chain : <Chain id=Q>
' G' ---> model : <Model id=0> chain : <Chain id=Q>
' U' ---> model : <Model id=0> chain : <Chain id=Q>
' U' ---> model : <Model id=0> chain : <Chain id=Q>
' U' ---> model : <Model id=0> chain : <Chain id=Q>
' U' ---> model : <Model id=0> chain : <Chain id=Q>
' U' ---> model : <Model id=0> chain : <Chain id=Q>
' U' ---> model : <Model id=0> chain : <Chain id=Q>
' U' ---> model : <Model id=0> chain : <Chain id=Q>
' U' ---> model : <Model id=0> chain : <Chain id=Q>
took ages because of the residue name for Ribonucleotides A, C, G, U, I
https://pdb101.rcsb.org/learn/guide-to-understanding-pdb-data/primary-sequences-and-the-pdb-format
that for the pdb format are actually ' A' (note empty blank spaces before letter A) and so on ...

Related

Put elements vertically from string list Jinja2 template

I am new in Ansible and recently using Jinja2 template for modifying deciphering rate data. I have data as below:
"msg":
"msg": [
" 10/13 17:00 37955454 (99.35%)",
" 10/13 16:00 95109950 (99.37%)",
" 10/13 15:00 97574440 (99.36%)",
" 10/13 14:00 98193064 (99.36%)",
" 10/13 13:00 95558001 (99.35%)",
]
I am looking for help to convert this data into
"msg": [
10/13 10/13 10/13 10/13 10/13
17:00 16:00 15:00 14:00 13:00
37955454 95109950 97574440 98193064 95558001
(99.35%) (99.37%) (99.36%) (99.36%) (99.35%)
]

Sitecore docker build. Invoke-RemoteScript.ps1 times out

Working on this for over 2 weeks and I'm run out of ideas.
Hoping for some1 experienced with dockerized Sitecore.
I have a Sitecore Docker (windows container) build and i'm trying to run script on it.
Sitecore is built with this tutorial: http://rockpapersitecore.com/2019/10/yet-another-sitecore-docker-series/
Script:
Write-Host "Preparing for DB upgrade"
Import-Module C:\automation\SPE
$session = New-ScriptSession -Username admin -Password b -ConnectionUri http://localhost
$jobId = Invoke-RemoteScript -Session $session -ScriptBlock {
Install-Package -Path C:\automation\CT_DB_upgrade.zip -InstallMode Merge -MergeMode Merge
} -AsJob
Start-Sleep -s 5
Wait-RemoteScriptSession -Session $session -Id $jobId -Delay 5 -Verbose
Write-Host "CT_DB_upgrade.zip installed"
Stop-ScriptSession -Session $session
More over script suppose to update clean DB with tables for our Sitecore connector.
Script works fine, tables are added and Sitecore works, but...script times out..
After "CT_DB_upgrade.zip installed" it runs for about 2min and times out.
Normally on VM script runs for about 0.5/ 1 sec and doesn't crash.
PS C:\automation> .\install-ct-db.ps1
Preparing for DB upgrade
VERBOSE: Checking the Runspace for the variable id.
VERBOSE: Preparing to invoke the script against the service at url
http://localhost/-/script/script/?sessionId=2ca051be-195d-4f0a-90b7-d084b9246ca3&rawOutput=False&persistentSession=F alse
VERBOSE: Transferring script to server
VERBOSE: Script transfer complete.
VERBOSE: Polling job 55ed096e-16ae-49cd-8d20-4d6a4ec219d1. Status : Available.
VERBOSE: Finished polling job 55ed096e-16ae-49cd-8d20-4d6a4ec219d1.
VERBOSE: Checking the Runspace for the variable id.
VERBOSE: Preparing to invoke the script against the service at url
http://localhost/-/script/script/?sessionId=2ca051be-195d-4f0a-90b7-d084b9246ca3&rawOutput=False&persistentSession=F alse
VERBOSE: Transferring script to server
VERBOSE: Script transfer complete.
CT_DB_upgrade.zip installed
Exception calling "Invoke" with "1" argument(s): "The operation has timed out"
At C:\automation\SPE\ConvertFrom-CliXml.ps1:24 char:9
+ $deserializer = $ctor.Invoke($xr)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
Exception calling "InvokeMember" with "5" argument(s): "Non-static method requires a target."
At C:\automation\SPE\ConvertFrom-CliXml.ps1:26 char:16
+ ... while (!$type.InvokeMember("Done", "InvokeMethod,NonPublic,Insta ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : TargetException
As i understand it crashes at: Stop-ScriptSession -Session $session.
I have tried changing different web.config settings, like timeouts, but even if i set timeout after 10min it will timeout anyway after around 2min.
Here is ConvertFrom-CliXml.ps1:
function ConvertFrom-CliXml {
param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
[ValidateNotNullOrEmpty()]
[String[]]$InputObject
)
begin
{
$OFS = "`n"
[String]$xmlString = ""
}
process
{
$xmlString += $InputObject
}
end
{
#This try catch ignores rest of the code and let script finish with no error.
#try {
$type = [PSObject].Assembly.GetType('System.Management.Automation.Deserializer')
$ctor = $type.GetConstructor('instance,nonpublic', $null, #([xml.xmlreader]), $null)
$sr = New-Object System.IO.StringReader $xmlString
$xr = New-Object System.Xml.XmlTextReader $sr
$deserializer = $ctor.Invoke($xr)
$done = $type.GetMethod('Done', [System.Reflection.BindingFlags]'nonpublic,instance')
while (!$type.InvokeMember("Done", "InvokeMethod,NonPublic,Instance", $null, $deserializer, #()))
{
try {
$type.InvokeMember("Deserialize", "InvokeMethod,NonPublic,Instance", $null, $deserializer, #())
} catch {
Write-Warning "Could not deserialize ${string}: $_"
}
}
$xr.Close()
$sr.Dispose()
#} catch {
# Write-Host "Could not finish script correctly"
<#
.SYNOPSIS
Short description
.DESCRIPTION
Long description
.PARAMETER InputObject
Parameter description
.EXAMPLE
An example
.NOTES
General notes
#>
}
}

groovy script to remove users from jenkins project role alone?

import hudson.security.*
import jenkins.security.*
import jenkins.model.Jenkins
def sids = Jenkins.instance.authorizationStrategy.getAllSIDs()
return sids
In the Build Section;
def removeAMP(Job jobName, user ) {
println jobName.name.center(80,'-')
def authorizationMatrixProperty = jobName.getProperty(AuthorizationMatrixProperty.class)
Map<Permission,Set<String>> Permissions = authorizationMatrixProperty.getGrantedPermissions()
println "Permission Map Before: " + Permissions + cr
println "Permission Values: " + Permissions.values() + cr
for (Set<String> permissionUsers:Permissions.values()) {
permissionUsers.remove(user)
}
println "Permission Map After: " + Permissions + cr
jobName.save();
}
I created a job in jenkins with "Execute system grrovy script" for removing users from project role not from jenkins global role.with following scripts,but am getting error as follows:
ERROR: Build step failed with exception
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 10: unable to resolve class Job
# line 10, column 19.
def removeAMP(Job jobName, user ) {
^
1 error
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:302)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:861)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:550)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:499)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:302)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:281)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:731)
at groovy.lang.GroovyShell.parse(GroovyShell.java:743)
at groovy.lang.GroovyShell.parse(GroovyShell.java:723)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:680)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:666)
at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:81)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1738)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Build step 'Execute system Groovy script' marked build as failure
Finished: FAILURE
Please help me with correct script.Thanks in advance
Ashif
Do you need to add
import hudson.model.Job

Jenkins pipeline groovy project job list

I want to list all jobs of my current project within my groovy pipeline script.
Does someone know how to do that? With
env.BRANCH_NAME
I am just getting my current branch.
you can get it from jenkins api, for example the URL:
http://jenkinsHost:8080/job/jobName/api/json?pretty=true&tree=jobs[name]
will produce something like:
{
"_class" : "org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject",
"jobs" : [
{
"_class" : "org.jenkinsci.plugins.workflow.job.WorkflowJob",
"name" : "develop"
},
{
"_class" : "org.jenkinsci.plugins.workflow.job.WorkflowJob",
"name" : "master"
},
{
"_class" : "org.jenkinsci.plugins.workflow.job.WorkflowJob",
"name" : "testing"
}
]
}
and then you can parse the branches names with groovy. (In the above case, "develop", "master" and "testing" are branches)

groovy execute intermittently returns no output nor error

I'm trying to use a Groovy script (to run with jenkins-cli.jar) to verify some git information.
To this end, I have the following simple groovy script:
def getBranchSha = { branch ->
def wd = new File('/my/git/repo');
def sout = new StringBuffer(), serr = new StringBuffer();
def gitcmd = 'git show-ref ' + branch + ' --hash';
def proc = gitcmd.execute(null, wd);
proc.consumeProcessOutput(sout, serr);
proc.waitFor();
def sha = sout.toString().trim();
out.println("exitCode: " + proc.exitValue() + "\terror: " + serr.toString());
out.println("input: " + branch + "\toutput: \"" + sha + "\"");
assert sha.equals("10d94325c8fc1050f3e362d2fbb9f9041e6b9360");
}
getBranchSha("origin/master");
I expect this to construct a command line git show-ref origin/master --hash and execute that in the working dir of my git repo. I expect the output of this to be the current SHA of my origin/master branch in this repo 10d94325c8fc1050f3e362d2fbb9f9041e6b9360, and the code asserts this to be the case.
Most of the time, this code runs exactly as expected, but sometimes for no reason I can see, the output is blank:
> while [ $? -eq 0 ] ; do java -jar jenkins-cli.jar -s http://localhost:8080 groovy tst.groovy ; done
exitCode: 0 error:
input: origin/master output: "10d94325c8fc1050f3e362d2fbb9f9041e6b9360"
exitCode: 0 error:
input: origin/master output: "10d94325c8fc1050f3e362d2fbb9f9041e6b9360"
...
exitCode: 0 error:
input: origin/master output: "10d94325c8fc1050f3e362d2fbb9f9041e6b9360"
exitCode: 0 error:
input: origin/master output: ""
java.lang.SecurityException: Rejected: org.codehaus.groovy.runtime.powerassert.PowerAssertionError
at hudson.remoting.ClassFilter.check(ClassFilter.java:20)
at hudson.remoting.MultiClassLoaderSerializer$Input.resolveClass(MultiClassLoaderSerializer.java:111)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1612)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1517)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
at hudson.remoting.UserRequest.deserialize(UserRequest.java:184)
at hudson.remoting.UserResponse.retrieve(UserRequest.java:217)
at hudson.remoting.Channel.call(Channel.java:781)
at hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:250)
at com.sun.proxy.$Proxy3.main(Unknown Source)
at hudson.cli.CLI.execute(CLI.java:338)
at hudson.cli.CLI._main(CLI.java:509)
at hudson.cli.CLI.main(CLI.java:390)
Based on the zero exit code, I assume that the command has executed normally, but I don't understand why the output hasn't been received. I thought that it might be because I don't understand how waitFor is supposed to work, but I've tried placing the proc.waitFor() line at various points in the function with no difference.
Running a similar script to verify that "pwd".execute().text.trim().equals("/") seems to always return correctly.
Any ideas?
I found a way that works. Rather than calling waitFor and consumeProcessOutput one after the other (in any order), the method waitForProcessOutput will reliably deliver the shell output to my groovy script.
def getBranchSha = { branch ->
def wd = new File('/my/git/repo');
def sout = new StringBuffer(), serr = new StringBuffer();
def gitcmd = 'git show-ref ' + branch + ' --hash';
def proc = gitcmd.execute(null, wd);
proc.waitForProcessOutput(sout, serr);
def sha = sout.toString().trim();
out.println("exitCode: " + proc.exitValue() + "\terror: " + serr.toString());
out.println("input: " + branch + "\toutput: \"" + sha + "\"");
assert sha.equals("10d94325c8fc1050f3e362d2fbb9f9041e6b9360");
}
getBranchSha("origin/master");
This code will give me what I want. I don't understand why a combination of waitFor and consumeProcessOutput doesn't do the same thing though.

Resources