Assume my target .bc file has two instruction,
%3 = load volatile i32* %i, align 4
%4 = load i32** %sum, align 8
Both of them are Load instruction. I would like to know how to extract the different variables %i and %sum for some conditional compare.
I have tried to print something like:
errs()<< instruction->getOperand(i)->getName(); // print out the ith operand's name
But it turns out that the things returned are garbled.
Hope anyone with same experience could help me.
This won't work in general - in particular either:
a) release mode can avoid putting names on individual instructions, they'll just be the next number in sequence (as you can see from the load instructions above), or
b) optimization passes will occasionally change the name as well.
The only way to do this is to either keep track of the variables as you emit them, or perform some analysis that tells you where you want to perform the compare.
Related
GDB is trying to be helpful by labeling what I believe are global variables, but in this case each global is more than 0x10 bytes and so the second part of the variable is printed on the next line, but with an offset added to its label, which throws off the alignment of the whole printout (generated by executing x/50wx 0x604130):
Is there a command to disable these labels while examining bytes?
Edit: to be more specific, I would like to printout exactly what is shown in the screenshot, just without the <n1> / <n1+16> labels that are throwing off the alignment of the columns
Is there a command to disable these labels while examining bytes?
I don't believe there is.
One might expect that set print symbol off would do it, but it doesn't.
The closest I can suggest is this answer.
I want to get the RMSD for each pair of poses generated by an autodock docking via the align function:
align pose1, pose2, cycles=0, transform=0
Instead of using the names of the poses as input, I want to access a list that contains all poses.
This list is successfully obtained via:
allobjects = cmd.get_object_list('all')
and
print(allobjects[x])
successfully prints the pose at position x in this list.
However, the following method did not work:
align allobjects[1], allobjects[2], cycles=0, transform=0
yields error: Invalid selection name "allobjects[1]"
What would be the correct way to feed the align function with the list indices?
Thank you in advance!
As far as I know, you can not pass values from python variables to the built-in functions of PyMOL. But there is almost always an equivalent python function that does the same and can receive regular pythonic arguments. In the case of align it would be cmd.align().
The result of cmd.align() is not printed as nice as the align function, but instead a list of 7 elements is returned, being the first element the calculated RMSD. The meaning of the rest of the values can be found in the source code of the function.
I also assume that you intent to calculate the RMSD for every possible pair of docked structures. For that purpose you have to use all the unique combinations of all structures and manually do a python loop over them. Be aware that the calculation time will increase exponentially with the number of structures you have.
allobjects = cmd.get_object_list('all')
from itertools import combinations
for pair in combinations(allobjects, 2): print(pair[0], pair[1], cmd.align(pair[0], pair[1], cycles=0, transform=0)[0])
so I've recently started a project about sequence alignment, and have used been using the standalone software programme 'MAFFT' to align some BRCA1 sequences (via. command-line)
I need to create a function which will produce all the pairwise combinations from aln files that I have produced using MAFFT. However I've been told that hard coding the alignments is not good practice e.g. first_alignment=align[0], second_alignment=align[1].
I've parsed the aln files using this code:
from Bio import AlignIO
align = AlignIO.read(aln_1, "clustal")
print(align)
align = AlignIO.read(aln_2, "clustal")
print(align)
Now I need a function to produced all the possible pairwise combinations, so that I can compare sequences and look for transitions/transversions, indels/substitutions, SNPs, or any biological significance.
Would appreciate the help!
Thanks.
You could loop through each of the alignments like shown on the official biopython site:
for record in alignment :
print(record.seq + " " + record.id)
To get both record you can add a inner loop like:
align1 = AlignIO.read(aln_1, "clustal")
align2 = AlignIO.read(aln_2, "clustal")
for record1 in alignment1 :
for record2 in alignment2:
# do comparison here
For the combination the pairwise module, I think has what you are looking for.
An example from the page is:
from Bio import pairwise2
alignments = pairwise2.align.globalxx("ACCGT", "ACG")
You can adjust that and pass as arguments for gloablxx the two records (inside the double loop) like:
alignments = pairwise2.align.globalxx(record1, record2)
Hope that is what you are looking for! :)
I'm writing an LLVM pass that analyses program and selects several basic blocks. I would like to store a list of selected blocks (BasicBlock*) into global metadata (and read back in subsequent passes). (There will be multiple BB lists, so I don't want to add metadata to BBs / terminator instructions.)
input:
Vector<BasicBlock*>
expected output:
!42 = !{BB1*, BB2*, ...}
I have found this related question, but I'm not able to convert a BasicBlock or an Instruction (e.g. a BB terminator) such that it is "correctly" saved in the metadata. One possible workaround is to save two strings – function name and BB name, but I would like to have a more robust solution.
What I'm really doing is trying to set a watchpoint on the setting or clearing of a single bit. I do that by setting a watchpoint on the word containing the bit, then making it conditional on *word & mask (for setting, or (~*word) & mask for clearing.)
The problem is that some other bit in the same word may be modified, and the condition may happen to already match. If I had the old and new values, I could set a condition of (($old ^ $new) & mask).
I looked at the python gdb.Breakpoint class, but it doesn't seem to receive this information either.
I suppose I could go crazy and set a command list that records the current value whenever the value of *word changes, and use that as $old. But half the time I'm using this, I'm actually using it through rr, so I might be going backwards.
There's no direct way to get these values in gdb; it's been a wish-list bug (with your exact case as the example...) for years.. The information is stored in the old_val field of the struct bpstats object associated with the breakpoint; but this is only used to print the old value and not exposed elsewhere.
One option might be to change gdb to expose this value via a convenience variable or via Python.
I suppose I could go crazy and set a command list that records the current value whenever the value of *word changes, and use that as $old. But half the time I'm using this, I'm actually using it through rr, so I might be going backwards.
This seems doable. Your script could check the current execution direction. The main difficulty is remembering to reset the saved value when making this watchpoint, or after disabling and then re-enabling it.