mastodon

1

votes
2

answer
1.8k

views

Storing group of objects with Dates in a Map

I have a group of Events that occurred at some Dates. Each event has a Date field. Now I'd like to create a Map where for each Date (taken from all dates of events) I will assign List of Events that occurred on that date. So in pseudocode : public Map function(List list){ Date[]dates = new Date(list...
mastodon
1

votes
4

answer
126

views

Testing implementation of '<T>' List

I have written my own implementation of java.utils.List. Now I'd like to test it, but I cannot manage to fill my collection with objects since it shows expected whenever I add anything : public static void main(String[] args) {} MyCollection col = new MyCollection(10); int[] tab = {1,2,4,5,6}; col....
mastodon
1

votes
2

answer
44

views

Analysing and calculating new values in list of lists in Python3

Well, I will try to explain myself correctly: I am working with python3 with a list of lists in the structure: [[position, color, counts],...] The results are ordered firstly by the color and after by position. I need to combine the counts and the mean of positions if they have the same color and th...
Mastodon
1

votes
1

answer
55

views

Improve genbank feature addition

I am trying to add more than 70000 new features to a genbank file using biopython. I have this code: from Bio import SeqIO from Bio.SeqFeature import SeqFeature, FeatureLocation fi = 'myoriginal.gbk' fo = 'mynewfile.gbk' for result in results: start = 0 end = 0 result = result.split('\t') start = i...
Mastodon
1

votes
1

answer
36

views

Trimming first characters of a line to match length of a second line

I am playing with some fastq files trimming specific sequences from the 2nd line of the fastq sequence: Input example: @D00733:159:CA65UANXX:8:1214:11297:78554 GTTTTACACAATTATACGGACTTTATCCGCTTTTGTGCCTCTTTAATTTC + BBCCCEGGGGGGGFGEGGGDGGGGGGGGGGGGGGFGGGGGGGGGGGGEGG @D00733:159:CA65UANXX:8:1214:11297:7...
Mastodon
1

votes
1

answer
137

views

linkedin v2 api: combine projection and decoration

Using Postman, I can query the endpoint to retrieve comments on a share: https://api.linkedin.com/v2/socialActions/urn:li:share:myshare/comments?count=35 and we have a response like { 'paging': { 'count': 10, 'start': 0 }, 'elements': [ { 'actor': 'urn:li:person:x', 'created': { 'actor': 'urn:li:per...
Mr. Mastodon Farm
0

votes
0

answer
6

views

How to count non-zeroes values using binned_statistic

I need to efficiently process very large 1D arrays extracting some statistics per bin and I have found very useful the function binned_statistic from scipy.stats as it includes a 'statistic' argument that works quite efficiently. I would like to perform a 'count' function but without considering zer...
Mastodon
2

votes
5

answer
1.2k

views

Collection for storing objects with date

I have some objects with Date parameters. What collection will be best for storing them and later querying for object/objects with particular date ? (like given as a String or java.util.Date format) ? EDIT: I was trying to use TofuBear's solution, but cannot make it work. let's say I am calling my f...
mastodon
2

votes
5

answer
37.9k

views

Style facebook 'like' button

I'm struggling with this for a while now and without any success. Setting the style with jquery doesn't work, the same with after the facebook iframe. Is there a way to perform this task ? .connect_widget_not_connected_text, .connect_widget_connected_text { color:white; } .connect_widget_connected_...
mastodon
2

votes
4

answer
1.8k

views

Sending GET to server gives no response (but status returned)

I'm sending an ajax request to my server that updates some data there. Request is sent with jquery's get function. On success I'd like te perform some action, but unfortunately whole operation fails since server gives no response, even though firebug clearly shows 200 status: What more, when I enter...
mastodon
2

votes
3

answer
118

views

Strange python's comparison behaviour

I have a sample code looking like this, values (position = 2, object.position = 3) : new_position = position old_position = object.position logging.debug('1. new_position: %s, old_position: %s' % (new_position, old_position)) if old_position != new_position: logging.debug('old position other tha...
mastodon
6

votes
5

answer
2.5k

views

Pause form submission for validation

I have some form, which uploads file in an iframe. I'd like to hold it's submission until I'll check if it's valid with ajax. How can I do this ? My code pauses the submission and returns validation result (currently just a dummy function which returns 'result': 'true') but then the 'submit' action...
mastodon
4

votes
2

answer
22.7k

views

Encode keys of dictionaries inside a list from unicode to ascii

I have sample response with friends list from facebook: [{u'uid': 513351886, u'name': u'Mohammed Hossein', u'pic_small': u'http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs643.snc3/27383_513351886_4933_t.jpg'}, {u'uid': 516583220, u'name': u'Sim Salabim', u'pic_small': u'http://profile.ak.fbcdn.net/hp...
mastodon
1

votes
1

answer
106

views

Filtering blast results by evalue but only if unique

I am working on a pipeline that at some point generates hundred of different files in the following format (I write X in the fields that I don't care about): id1 X X X X X X X X X evalue1 X id2 X X X X X X X X X evalue2 X ... I have to filter this file...
Mastodon
4

votes
5

answer
46.4k

views

Read multiline text with values separated by whitespaces

I have a following test file : Jon Smith 1980-01-01 Matt Walker 1990-05-12 What is the best way to parse through each line of this file, creating object with (name, surname, birthdate) ? Of course this is just a sample, the real file has many records.
mastodon
4

votes
3

answer
2.6k

views

Casting Objects to <T>-type

I'm implementing List interface to a class which stores data in a type array. This raises problems with methods that take Collection as parameters, since collection stores it's objects as Object. How can I transform Object to T ? Simple casting doesn't work. class MyCollection implements List{ T[]...
mastodon
1

votes
3

answer
333

views

Replacing whitespaces within list elements

I have a list of tags: >>> tags_list ['tag1', 'second tag', 'third longer tag'] How can I replace whitespaces within each element of the list with '+' ? I was trying to do this with regular expressions but each string remains unchanged: for tag in tags_list: re.sub('\s+' , ' ', tag) What is wrong wi...
mastodon
6

votes
5

answer
3.4k

views

Retrieving response from remote server after uploading a file in iframe

I have a form that uploads a file in an firame to a remote server. As a result at the submission url server returns json data with the result of operation, which my iframe catches. {'result': 'true' or 'false'} Now I'd like to retrieve this json as the callback of my iframe. I know that I need jsonp...
mastodon
1

votes
1

answer
219

views

Form doesn't accept additional parameters

I was trying to pass an additional parameter to my form, which is anObject to ForeignKey relation. But dunno why form returns __init__() got an unexpected keyword argument 'parent' when I'm pretty sure that it is possible to send additional parameters to form's __init__ (ie here : Simple form not va...
mastodon
3

votes
3

answer
13.6k

views

Workaround for adding ActionListener to JTextArea

I have a program that get's input string with file path in one JTextArea and then loads it's content to a second JTextArea. Problem is that when using JTextArea I cannot add an actionListener that will load content in the second JTextArea when leaving this field. How to get around this problem ? pro...
mastodon