Script to extract
Dear,
I have two file. In one there is start and end position. I want to use these start and end position to extract information in another txt file( start and end position in column 2)
File 1 format
CcLG11:226909-229893
CcLG11:243545-252363
CcLG11:468465-470135
CcLG11:599949-606369
CcLG11:702863-705567
CcLG11:732897-733190
CcLG11:777699-778472
CcLG11:836376-837089
CcLG11:863645-868932
CcLG11:885839-889335
CcLG11:894027-895799
File2 format
CcLG01 114 - CG 0.000 2.00 0 2 0 0 0.000 0.658
CcLG01 136 - CG 0.000 1.00 0 1 0 0 0.000 0.793
CcLG01 243 - CG 0.000 1.00 0 1 0 0 0.000 0.793
CcLG01 1272 + CG 0.000 1.00 0 1 1 1 0.000 0.793
CcLG01 1273 - CG 1.000 1.00 1 1 1 1 0.207 1.000
CcLG01 1277 + CG 1.000 1.00 1 1 1 1 0.207 1.000
CcLG01 1278 - CG 1.000 1.00 1 1 1 1 0.207 1.000
CcLG01 1281 + CG 1.000 1.00 1 1 1 1 0.207 1.000
CcLG01 1282 - CG 1.000 1.00 1 1 1 1 0.207 1.000
CcLG01 1287 + CG 1.000 1.00 1 1 1 1 0.207 1.000
CcLG01 1288 - CG 1.000 1.00 1 1 1 1 0.207 1.000
CcLG01 1296 + CG 1.000 1.00 1 1 0 0 0.207 1.000
CcLG01 1327 + CG 1.000 3.00 3 3 10 10 0.438 1.000
CcLG01 1328 - CG 1.000 12.00 12 12 3 3 0.757 1.000
CcLG01 1347 + CG 0.792 7.58 6 8 36 38 0.438 0.949
CcLG01 1348 - CG 1.000 38.00 38 38 8 8 0.908 1.000
CcLG01 1351 + CG 0.891 6.74 6 8 32 38 0.513 0.984
CcLG01 1352 - CG 1.000 28.50 32 38 6 8 0.881 1.000
CcLG01 1359 + CG 1.000 8.00 8 8 38 38 0.676 1.000
• 1,603 views
•
link
2 answers
See also my question above:
Does the value on position 13500 belong to the interval 13500 to 14800 or not? What about the value on position 14800? Essentially: inclusive or non-inclusive intervals? :-)
I don't have access to your data, so you will have to do the testing. Please give feedback.
• 0 views
•
link
need a loan contact stanbic IBTC loans for assistance email stanbicfinanzia@gmail.com
• 0 views
•
link
Log in to answer this question.
Looks like people are too busy to spend time to write appropriate title and making the description understandable.
Do you have any solution.
Where is the "start and end position in column 2" in file 2?
start and end position are same in file 2..and based on file 1 ( start and end ) . for exampl file 1 chr start end
CcLg01 100 800 Then this position should be used to extract the information in file 2 (range of column 2 from 100-800).
And out put should be CcLg01 100 800 sum of column 7 sum of column8
Thank You
I still don't understand where start and stop in file 2 is. Column 2 seems to only hold a single number (e.g. only start or only end), but not both.
Could you based on this example add the desired output? As of now, your question is unclear and you probably won't get a helpful answer. Spend some more time constructing your post, chose a more appropriate title and you'll be more likely to get what you want.
Is there a link with Script For R or perl ?
In file 2 column 2 is start and end. like if in file 1,
File 1
File 2
My output
in file 2, column 7 is a position of specific nucleotide and in file2 there is a range (start - end) and i have to sum of the value (col7, col8) of nucleotide in the range given in file1.
So my output will be
Chr start end sum.col7 sum.col.8 CcLG11 226909 229893 ? ?
So from 228909 - 229893 (range) in file2
So in File 2 columns V1, V3, V4, V5, V8, V9, V10 and V11 are not required and therefore just adding noise to this question? If so, remove those. We cannot guess what you want, don't make things harder than it already is.
File1
File2
Output
From range 13500 to 14800 in file2 . This range should be used in file 1 to add column3 (M) and Col4(x) of file2
In file1 column 2 is position so the position 13883 to 14347 will fall in the range of 13500 to 14800.
So you want to add up the values in columns 3 and 4 in
file 1for rows where the value in column 2 lies within a range as specified bystartandendinfile 2?I think we are narrowing it down...
A custom python script could do the trick, but perhaps we can get away with a bedtools or GRanges solution, too.
Exactly...That is the exact, i want to do.
Thank You for your time and concern.
Does the value on position 13500 belong to the interval 13500 to 14800 or not? What about the value on position 14800?
Essentially: inclusive or non-inclusive intervals? :-)
I am getting this error. the file I used is attached.
Traceback (most recent call last):
Please add your comment to the relevant post and not just randomly, this makes things rather confusing.
Let's make sure you use the arguments correctly, corresponding to your example data above you should use the script as such:
Dear,
I am still getting error "IndexError: list index out of range".
Thank You
What is your column separator? Spaces or tabs?
I updated my code, please try again. It should identify the line causing this error.
drkishor@Dr:~/Desktop$ python extract.py pos_sam.txt Final_sam.txt INPUT ERROR AT FOLLOWING LINE: CcLG01 21694 22357
Plz find the attached file which i have used
There is no attached file. Switch the arguments.
Hello alim.hcu!
We believe that this post does not fit the main topic of this site.
Not a bioinformatics question. The question has several further issues, after a long back-and-forth discussion it remains totally unclear what the desired output is, the example data given is possibly inadequate etc.
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!
But i don,t know, who has posted this post. i think it may be a spam.
Thank You
Yes, there was a spam post here and I removed it.
But the arguments of Michael have nothing do with spam: