Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Given snippet: <|code_start|> line = NAMED_LINKS_REGEX.sub(r'\1', line)
line = line.replace('[', '').replace(']', '')
section_name = line.strip('=').strip()
# Stop when we get to "See also" or "References".
... | if line.startswith("''Note:"): |
Continue the code snippet: <|code_start|> bulk_import__slug=self.slug,
)
return False
except ImportedEndorsement.DoesNotExist:
if self.create:
ImportedEndorsement.objects.create(
bulk_import=self.b... | lines = wikitext.splitlines() |
Using the snippet: <|code_start|>
COMMENTS_REGEX = re.compile(r'<!--.*?-->')
COLON_SECTION_REGEX = re.compile('(\[?\[?[a-zA-Z ]+)\]?\]?: ')
URL = 'https://en.wikipedia.org/w/api.php?action=parse&page={slug}&prop=wikitext&format=json'
NAMED_LINKS_REGEX = re.compile(r'\[\[[^|\]]+\|([^\]]+)\]\]')
class Command(BaseCom... | try: |
Based on the snippet: <|code_start|> current_line_sections,
)
current_line = []
if line.startswith('* '):
line = line[2:]
if line == '[[List of Donald Trump presidential campaign primary endorsements,... | if '<!--' in line: |
Given the following code snippet before the placeholder: <|code_start|>
COMMENTS_REGEX = re.compile(r'<!--.*?-->')
COLON_SECTION_REGEX = re.compile('(\[?\[?[a-zA-Z ]+)\]?\]?: ')
URL = 'https://en.wikipedia.org/w/api.php?action=parse&page={slug}&prop=wikitext&format=json'
NAMED_LINKS_REGEX = re.compile(r'\[\[[^|\]]+... | class Command(BaseCommand): |
Continue the code snippet: <|code_start|> colon_section = colon_section.replace(']', '')
line_remainder = line.partition(':')[2]
for sub_line in split_endorsements(line_remainder):
num_imported += self.import_endorsement(... | current_depth = line.count('=') / 2 - 2 |
Given snippet: <|code_start|>
URL = 'https://en.wikipedia.org/w/api.php?action=parse&page={slug}&prop=text&format=json§ion={section}'
SLUG = 'Current_members_of_the_United_States_House_of_Representatives'
SECTION = 7
class Command(BaseCommand):
help = 'Bulk import all the election results by state'
<|code_... | def add_arguments(self, parser): |
Next line prediction: <|code_start|>
URL = 'https://en.wikipedia.org/w/api.php?action=parse&page={slug}&prop=text&format=json§ion={section}'
SLUG = 'Current_members_of_the_United_States_House_of_Representatives'
SECTION = 7
class Command(BaseCommand):
help = 'Bulk import all the election results by state'
... | reps = [] |
Given the following code snippet before the placeholder: <|code_start|>
def add_arguments(self, parser):
parser.add_argument(
'--create',
action='store_true',
dest='create',
default=False,
help="Creates everything (otherwise, it's a dry run)",
... | state = state_string.rpartition(' ')[0] |
Based on the snippet: <|code_start|>from __future__ import unicode_literals
class BulkImport(models.Model):
slug = models.SlugField(max_length=255)
created_at = models.DateTimeField(auto_now_add=True)
text = models.TextField()
def __unicode__(self):
return str(self.created_at)
class Impor... | bulk_import = models.ForeignKey(BulkImport) |
Continue the code snippet: <|code_start|>
class ImportedRepresentative(models.Model):
bulk_import = models.ForeignKey(BulkImport)
state = models.ForeignKey(
Tag,
limit_choices_to={
'category': 8,
},
related_name='+',
)
confirmed_endorser = models.ForeignKey(E... | if ' ' in name: |
Given the following code snippet before the placeholder: <|code_start|> 'category': 8,
},
related_name='+',
)
confirmed_endorser = models.ForeignKey(Endorser, blank=True, null=True)
party = models.ForeignKey(
Tag,
limit_choices_to={
'category': 2
... | name__istartswith=first_name_start, |
Given the code snippet: <|code_start|> if ' ' in name:
split_name = name.split(' ')
first_name_start = split_name[0][:3]
last_name = split_name[-1]
if len(last_name) > 3:
query = Endorser.objects.filter(
name__iendswith=last_name... | count=self.count |
Predict the next line for this snippet: <|code_start|>
class Command(BaseCommand):
help = 'Bulk import all the newspaper endorsements'
def add_arguments(self, parser):
parser.add_argument('endorser_pk', type=int)
parser.add_argument('tags', nargs='+')
parser.add_argument(
<|code_end|>... | '--remove', |
Next line prediction: <|code_start|>
class Command(BaseCommand):
help = 'Bulk import all the newspaper endorsements'
def add_arguments(self, parser):
parser.add_argument('endorser_pk', type=int)
<|code_end|>
. Use current file imports:
(from django.core.management.base import BaseCommand, CommandErr... | parser.add_argument('tags', nargs='+') |
Predict the next line for this snippet: <|code_start|>
class Command(BaseCommand):
help = 'Refresh the current_position field for all Endorsers'
def handle(self, *args, **options):
<|code_end|>
with the help of current file imports:
from django.core.management.base import BaseCommand, CommandError
from end... | n = 0 |
Based on the snippet: <|code_start|>
print row
rows.append(row)
# Now get all the references.
references = {}
for li in soup.findAll('li'):
ref_id = li['id'].replace('_note-', '_ref-')
cite = li.find('cite')
... | endorsement_2016=row['2016'], |
Using the snippet: <|code_start|>
URL = 'https://en.wikipedia.org/w/api.php?action=parse&page={slug}&prop=text&format=json§ion={section}'
SLUG = 'Newspaper_endorsements_in_the_United_States_presidential_election,_2016'
class Command(BaseCommand):
help = 'Bulk import all the newspaper endorsements'
def ... | action='store_true', |
Given the following code snippet before the placeholder: <|code_start|>
URL = 'https://en.wikipedia.org/w/api.php?action=parse&page={slug}&prop=text&format=json§ion={section}'
SLUG = 'Newspaper_endorsements_in_the_United_States_presidential_election,_2016'
class Command(BaseCommand):
help = 'Bulk import all... | def handle(self, *args, **options): |
Given the code snippet: <|code_start|>
class Html5DateInput(forms.DateInput):
input_type = 'date'
class SourceForm(forms.ModelForm):
class Meta:
model = Source
exclude = ('name',)
widgets = {
'date': Html5DateInput(),
}
class PersonalTagForm(forms.Form):
tag... | tag = forms.ModelChoiceField( |
Using the snippet: <|code_start|> )
source_name = forms.CharField(
widget=forms.TextInput(attrs={'placeholder': 'e.g., Politico'})
)
event = forms.ModelChoiceField(Event.objects.all(), required=False)
class EndorsementFormWithoutPosition(EndorsementForm):
position = None
source_name = f... | ) |
Predict the next line for this snippet: <|code_start|> Tag.objects.filter(is_personal=False)
)
class TagFilterForm(forms.Form):
filter_tags_show = forms.ModelMultipleChoiceField(
Tag.objects.all(), required=False
)
filter_tags_hide = forms.ModelMultipleChoiceField(
Tag.objects.a... | source_name = forms.CharField( |
Given the following code snippet before the placeholder: <|code_start|> widget=forms.Textarea(attrs={'rows': 1}),
required=False,
)
context = forms.CharField(
widget=forms.Textarea(attrs={
'rows': 1,
'placeholder': 'e.g., "In an editorial endorsement" (leave blank ... | widget=forms.Textarea(attrs={'rows': 4}), |
Using the snippet: <|code_start|> seqs = SffExtractor([open(sff_fpath, 'rb')], min_left_clip=5,
trim=True).seqs
seqs = list(seqs)
assert len(seqs) == 10
assert str(seqs[0].seq).startswith('GTCTACATGTTGGTTAACCCGTACTGAT')
# empty file
empty_fhand... | seqs = extractor.seqs |
Predict the next line after this snippet: <|code_start|> assert extractor.clip_advice[sff_fpath] == (5, 'A')
extractor = SffExtractor([open(sff_fpath, 'rb')], min_left_clip=4,
trim=False)
seqs = extractor.seqs
seqs = list(seqs)
assert len(seqs) == 10
... | assert 'usage' in check_output([sff_bin, '-h']) |
Given the code snippet: <|code_start|> seqs = extractor.seqs
seqs = list(seqs)
assert len(seqs) == 10
assert extractor.clip_advice[sff_fpath] == (5, 'A')
extractor = SffExtractor([open(sff_fpath, 'rb')], min_left_clip=4,
trim=True)
seqs = extra... | stderr = NamedTemporaryFile() |
Next line prediction: <|code_start|> seq = SeqWrapper(SEQITEM, seq, 'fasta')
seq2 = copy_seq(seq, seq='ACTG')
assert seq2.object == SeqItem(name='s1', lines=['>s1\n', 'ACTG\n'],
annotations={'a': 'b'})
assert seq.object is not seq2.object
asse... | {}) |
Based on the snippet: <|code_start|> expected_seq = SeqWrapper(SEQITEM, expected_seq, 'fasta')
assert slice_seq(seq, 1, 5) == expected_seq
# with fastq
seq = SeqItem(name='seq',
lines=['@seq\n', 'aata\n', '+\n', '!?!?\n'])
seq = SeqWrapper(SEQITEM, seq, 'fas... | annotations={'a': 'b'}) |
Next line prediction: <|code_start|> seq = SeqItem(name='s1', lines=['>s1\n', 'ACTGGTAC\n'])
seq = SeqWrapper(SEQITEM, seq, 'fasta')
assert get_length(seq) == 8
# with fastq
seq = SeqItem(name='seq',
lines=['@seq\n', 'aaaa\n', '+\n', '????\n'])
seq =... | except AttributeError: |
Next line prediction: <|code_start|> assert seq.object.lines == ['@seq\n', 'at\n', '+\n', '?!\n']
# with multiline fastq
seq = SeqItem(name='seq', lines=['@seq\n', 'aaatcaaa\n', '+\n',
'@AAABBBB\n'])
seq = SeqWrapper(SEQITEM, seq, 'fastq-illumina'... | lines=['@seq\n', 'aaaa\n', '+\n', '!???\n']) |
Continue the code snippet: <|code_start|> assert get_str_seq(seq_) == get_str_seq(seq)[1: 5]
# It tests the stop is None
seq = SeqItem('seq', ['>seq\n', 'aCTG'])
seq = SeqWrapper(SEQITEM, seq, 'fasta')
assert get_str_seq(slice_seq(seq, 1, None)) == 'aCTG'[1:]
assert get_... | '@AAABBBB\n']) |
Predict the next line for this snippet: <|code_start|>
# with fastq
seq = SeqItem(name='seq',
lines=['@seq\n', 'aaaa\n', '+\n', '!???\n'])
seq = SeqWrapper(SEQITEM, seq, 'fastq')
seq2 = copy_seq(seq, seq='ACTG')
assert seq2.object == SeqItem(name='seq',
... | {}) |
Here is a snippet: <|code_start|> assert get_str_seq(slice_seq(seq, 1, None)) == 'aCTG'[1:]
assert get_str_seq(slice_seq(seq, None, 1)) == 'aCTG'[:1]
def test_copy(self):
# with fasta
seq = SeqItem(name='s1', lines=['>s1\n', 'ACTG\n', 'GTAC\n'],
annotations={'a... | '@AAABBBB\n']) |
Given snippet: <|code_start|> seq = SeqItem(name='s1', lines=['>s1\n', 'ACTGGTAC\n'])
seq = SeqWrapper(SEQITEM, seq, 'fasta')
expected_seq = SeqItem(name='s1', lines=['>s1\n', 'CTGG\n'])
expected_seq = SeqWrapper(SEQITEM, expected_seq, 'fasta')
assert slice_seq(seq, 1, 5) == expec... | def test_copy(self): |
Continue the code snippet: <|code_start|> seq = SeqItem(name='s1', lines=['>s1\n', 'ACTGGTAC\n'])
seq = SeqWrapper(SEQITEM, seq, 'fasta')
expected_seq = SeqItem(name='s1', lines=['>s1\n', 'CTGG\n'])
expected_seq = SeqWrapper(SEQITEM, expected_seq, 'fasta')
assert slice_seq(seq, 1,... | def test_copy(self): |
Using the snippet: <|code_start|> type=argparse.FileType('wt'))
parser.add_argument('--version', action='version',
version=build_version_msg())
group = parser.add_mutually_exclusive_group()
group.add_argument('-z ', '--gzip', action='store_true',
... | elif string.isdigit(): |
Given snippet: <|code_start|>
parser.add_argument('input', default=sys.stdin, nargs='*',
help='Sequence input files to process (default STDIN)',
type=argparse.FileType('rt'))
hlp_fmt = 'Format of the input files (default: %(default)s)'
parser.add_argument('-t... | parser.add_argument('-p', '--processes', dest='processes', type=int, |
Based on the snippet: <|code_start|> help='Compress the output in gzip format')
group.add_argument('-Z ', '--bgzf', action='store_true',
help='Compress the output in bgzf format')
group.add_argument('-B ', '--bzip2', action='store_true',
help='... | parser = argparse.ArgumentParser(parents=[parser], add_help=False) |
Next line prediction: <|code_start|># You should have received a copy of the GNU General Public License
# along with seq_crumbs. If not, see <http://www.gnu.org/licenses/>.
def create_basic_argparse(**kwargs):
'It returns a parser with several inputs and one output'
parser = argparse.ArgumentParser(**kwargs... | group.add_argument('-B ', '--bzip2', action='store_true', |
Predict the next line for this snippet: <|code_start|> # closed
args = {'out_fhand': out_fhand, 'in_fhands': wrapped_fhands,
'out_format': out_format, 'original_in_fhands': in_fhands}
return args, parsed_args
def parse_basic_parallel_args(parser):
'It parses the command line and it returns ... | args['fail_drags_pair'] = fail_drags_pair |
Given snippet: <|code_start|> help='Do not trim, only mask by lowering the case')
group = parser.add_argument_group('Pairing')
group.add_argument('--paired_reads', action='store_true',
help='Trim considering interleaved pairs')
group.add_argument('-e', '--orpha... | for wrapped_fhand in wrapped_fhands: |
Predict the next line after this snippet: <|code_start|>
def parse_filter_args(parser, add_reverse=True):
'It parses the command line and it returns a dict with the arguments.'
args, parsed_args = parse_basic_parallel_args(parser)
if add_reverse:
args['reverse'] = parsed_args.reverse
args['filte... | return args, parsed_args |
Using the snippet: <|code_start|> elif string.lower()[0] == 't':
return True
elif string.isdigit():
return bool(int(string))
def create_filter_argparse(add_reverse=True, **kwargs):
'It returns a cmd parser for the filter executables'
parser = create_basic_parallel_argparse(**kwargs)
... | parser.add_argument('-m', '--mask', dest='mask', action='store_true', |
Given the following code snippet before the placeholder: <|code_start|># You should have received a copy of the GNU General Public License
# along with seq_crumbs. If not, see <http://www.gnu.org/licenses/>.
def create_basic_argparse(**kwargs):
'It returns a parser with several inputs and one output'
parser... | group.add_argument('-B ', '--bzip2', action='store_true', |
Given the following code snippet before the placeholder: <|code_start|># along with seq_crumbs. If not, see <http://www.gnu.org/licenses/>.
# pylint: disable=R0201
# pylint: disable=R0904
# pylint: disable=C0111
class UppercaseLengthTest(unittest.TestCase):
'It tests the uppercase character count'
def tes... | def test_masked_locations(): |
Predict the next line for this snippet: <|code_start|> 'It tests the case change'
def test_case_change(self):
'It changes the case of the sequences'
seqs = [SeqRecord(Seq('aCCg'), letter_annotations={'dummy': 'dddd'})]
seqs = assing_kind_to_seqs(SEQRECORD, seqs, None)
change_case ... | assert '@seq1\nATCGT\n+' in result |
Given the following code snippet before the placeholder: <|code_start|> seqs = [SeqRecord(Seq('aCCg'), letter_annotations={'dummy': 'dddd'})]
seqs = assing_kind_to_seqs(SEQRECORD, seqs, None)
change_case = ChangeCase(action=UPPERCASE)
strs = [get_str_seq(s) for s in change_case(seqs)]
... | if __name__ == "__main__": |
Using the snippet: <|code_start|> fhand = NamedTemporaryFile()
fhand.write(content)
fhand.flush()
return fhand
class MaskedSegmentsTest(unittest.TestCase):
'It tests the lower case segments location functions'
@staticmethod
def test_masked_locations():
'It test the masked locations... | def test_case_change(self): |
Predict the next line for this snippet: <|code_start|>class ChangeCaseTest(unittest.TestCase):
'It tests the case change'
def test_case_change(self):
'It changes the case of the sequences'
seqs = [SeqRecord(Seq('aCCg'), letter_annotations={'dummy': 'dddd'})]
seqs = assing_kind_to_seqs(SE... | result = check_output([change_bin, '-a', 'upper', fastq_fhand.name]) |
Continue the code snippet: <|code_start|> change_case = ChangeCase(action=UPPERCASE)
strs = [get_str_seq(s) for s in change_case(seqs)]
assert strs == ['ACCG']
seqs = [SeqRecord(Seq('aCCg'))]
seqs = assing_kind_to_seqs(SEQRECORD, seqs, None)
change_case = ChangeCase(actio... | unittest.main() |
Continue the code snippet: <|code_start|> seqs = [SeqRecord(Seq('aCCg'), letter_annotations={'dummy': 'dddd'})]
seqs = assing_kind_to_seqs(SEQRECORD, seqs, None)
change_case = ChangeCase(action=UPPERCASE)
strs = [get_str_seq(s) for s in change_case(seqs)]
assert strs == ['ACCG']
... | if __name__ == "__main__": |
Here is a snippet: <|code_start|>def _make_fhand(content=''):
'It makes temporary fhands'
fhand = NamedTemporaryFile()
fhand.write(content)
fhand.flush()
return fhand
class MaskedSegmentsTest(unittest.TestCase):
'It tests the lower case segments location functions'
@staticmethod
def t... | class ChangeCaseTest(unittest.TestCase): |
Given snippet: <|code_start|>
@staticmethod
def test_masked_locations():
'It test the masked locations function'
assert list(get_uppercase_segments('aaATTTTTTaa')) == [(2, 8)]
assert list(get_uppercase_segments('aaATTTaTTaa')) == [(2, 5), (7, 8)]
assert list(get_uppercase_segm... | seqs = [SeqRecord(Seq('aCCg'))] |
Given the code snippet: <|code_start|># Copyright 2012 Jose Blanca, Peio Ziarsolo, COMAV-Univ. Politecnica Valencia
# This file is part of seq_crumbs.
# seq_crumbs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundatio... | 'It counts the number of uppercase letters in a string' |
Continue the code snippet: <|code_start|>
cmd.extend([in_fpath])
if regions:
regions = ['{0}:{1}-{2}'.format(*s) for s in regions.segments]
cmd.extend(regions)
pysam.view(*cmd)
def sort_bam(in_bam_fpath, out_bam_fpath=None):
if out_bam_fpath is None:
out_bam_fpath = in_bam_f... | shutil.move(temp_out_fpath, out_bam_fpath) |
Next line prediction: <|code_start|>
cmd.extend([in_fpath])
if regions:
regions = ['{0}:{1}-{2}'.format(*s) for s in regions.segments]
cmd.extend(regions)
pysam.view(*cmd)
def sort_bam(in_bam_fpath, out_bam_fpath=None):
if out_bam_fpath is None:
out_bam_fpath = in_bam_fpath
... | shutil.move(temp_out_fpath, out_bam_fpath) |
Next line prediction: <|code_start|> out_bam_fpath = in_bam_fpath
if out_bam_fpath == in_bam_fpath:
realigned_fhand = NamedTemporaryFile(suffix='.realigned.bam',
delete=False)
temp_out_fpath = realigned_fhand.name
else:
temp_out_fpath ... | cmd.append('I={}'.format(in_fpath)) |
Here is a snippet: <|code_start|>
class CloseToSnv(BaseAnnotator):
'''Filter snps with other close snvs.
Allowed snv_types: [snp, indel, unknown] '''
def __init__(self, distance=60, max_maf_depth=None, snv_type=None):
self.distance = distance
self.random_reader = None
self.max_ma... | if max_maf_depth is None and snv_type is None: |
Predict the next line after this snippet: <|code_start|> object=SeqItem(name, lines, annotations),
file_format=fmt)
return seq
def copy_seq(seqwrapper, seq=None, name=None):
seq_class = seqwrapper.kind
seq_obj = seqwrapper.object
if seq_class == SEQITEM:
... | else: |
Predict the next line for this snippet: <|code_start|> msg = 'Unknown or not supported quality format'
raise ValueError(msg)
return ''.join([quals_map[int_quality] for int_quality in int_quals])
def get_str_qualities(seq, out_format=None):
if out_format is None:
out_format = seq.file_fo... | quals = _int_quals_to_str_quals(int_quals, out_format) |
Next line prediction: <|code_start|> if 'illumina' in fmt:
quals_map = ILLUMINA_QUALS
else:
quals_map = SANGER_QUALS
encoded_quals = seqwrap.object.lines[3].rstrip()
quals = [quals_map[qual] for qual in encoded_quals]
else:
raise RuntimeError('Qualities... | quals_map = SANGER_STRS |
Next line prediction: <|code_start|> fmt = None
return fmt
def _break():
raise StopIteration
def _is_fastq_plus_line(line, seq_name):
if line == '+\n' or line.startswith('+') and seq_name in line:
return True
else:
return False
def _get_seqitem_quals(seq):
fmt = seq.file... | seq = str(seq.object.seq) |
Continue the code snippet: <|code_start|> return quals
def get_str_seq(seq):
seq_class = seq.kind
if seq_class == SEQITEM:
seq = seq.object.lines[1].strip()
elif seq_class == SEQRECORD:
seq = str(seq.object.seq)
return seq.strip()
def get_length(seq):
return len(get_str_seq(se... | quals = [quals_map[qual] for qual in encoded_quals] |
Given snippet: <|code_start|> out_format = ILLUMINA_QUALITY
seq_class = seq.kind
if seq_class == SEQITEM:
in_format = seq.file_format
if 'fasta' in in_format:
raise ValueError('A fasta file has no qualities')
if in_format in SANGER_FASTQ_FORMATS:
in_format... | def _copy_seqrecord(seqrec, seq=None, name=None, id_=None): |
Given the following code snippet before the placeholder: <|code_start|> if seq_class == SEQITEM:
seq = _copy_seqitem(seqwrapper, seq=seq, name=name)
elif seq_class == SEQRECORD:
seq_obj = _copy_seqrecord(seq_obj, seq=seq, name=name, id_=name)
seq = SeqWrapper(kind=seqwrapper.kind, object=... | seq_class = seq.kind |
Given the following code snippet before the placeholder: <|code_start|> type=argparse.FileType('w'))
msg = 'File to print some statistics (default STDERR)'
parser.add_argument('-l', '--log', help=msg, type=argparse.FileType('w'),
default=sys.stderr)
return par... | args = {'in_fhand': in_fhand, 'log_fhand': log_fhand, |
Continue the code snippet: <|code_start|>
def __init__(self, min_qual):
self._min_qual = min_qual
def __call__(self, snv):
return snv.remove_gt_from_low_qual_calls(min_qual=self._min_qual)
class HetGenotypeFilter(object):
def __call__(self, snv):
return snv.remove_gt_from_het_cal... | RIL_FREQ_AA_CACHE[n_generation] = freq_aa |
Given snippet: <|code_start|> if genotypic_freqs_method == HW:
allele_freqs = snv.allele_freqs
if not allele_freqs:
num_samples = len(snv.record.samples)
self.log['not_enough_individuals'] += num_samples
self.log['tot'] += num_samples
... | depth = call.allele_depths[allele] |
Given the code snippet: <|code_start|>
# pylint: disable=C0111
class SortTest(unittest.TestCase):
def test_sort_bam_bin(self):
bin_ = os.path.join(BIN_DIR, 'sort_bam')
assert 'usage' in check_output([bin_, '-h'])
bam_fpath = os.path.join(TEST_DATA_DIR, 'seqs.bam')
sorted_fhand ... | sorted_fhand.name]) |
Predict the next line after this snippet: <|code_start|>
# pylint: disable=C0111
class SortTest(unittest.TestCase):
def test_sort_bam_bin(self):
bin_ = os.path.join(BIN_DIR, 'sort_bam')
assert 'usage' in check_output([bin_, '-h'])
bam_fpath = os.path.join(TEST_DATA_DIR, 'seqs.bam')
<|c... | sorted_fhand = NamedTemporaryFile(suffix='.sorted.bam') |
Given snippet: <|code_start|>
# no index
sorted_fhand = NamedTemporaryFile()
check_call([bin_, bam_fpath, '-o', sorted_fhand.name, '--no-index'])
assert not os.path.exists(sorted_fhand.name + '.bai')
# sort the sam file
fhand = NamedTemporaryFile()
fhand.write(op... | samfile = pysam.Samfile(out_fpath) |
Given the code snippet: <|code_start|> merge_sams([bam_fpath, bam_fpath], out_fpath=out_fpath)
samfile = pysam.Samfile(out_fpath)
assert len(list(samfile)) == 2
assert os.stat(bam_fpath) != os.stat(out_fpath)
finally:
if os.path.exists(out_fpath):
... | realigned_fhand = NamedTemporaryFile(suffix='.realigned.bam') |
Given snippet: <|code_start|>
# pylint: disable=C0111
class SortTest(unittest.TestCase):
def test_sort_bam_bin(self):
bin_ = os.path.join(BIN_DIR, 'sort_bam')
assert 'usage' in check_output([bin_, '-h'])
bam_fpath = os.path.join(TEST_DATA_DIR, 'seqs.bam')
sorted_fhand = NamedTe... | fhand.write(open(bam_fpath).read()) |
Predict the next line after this snippet: <|code_start|> max_ = intcounter.max
axes.bar(index + 0.5, quart[2] - quart[0], bottom=quart[0],
width=bar_width, facecolor='none', align='center')
# median
axes.plot([index + 0.5 - bar_width / 2, index + 0.5 + bar_width / 2],
... | canvas.print_figure(fhand) |
Here is a snippet: <|code_start|> return True
else:
return False
log1 = math.log(float(num1))
log2 = math.log(float(num2))
return abs(log1 - log2) < ratio
def _check_sequence(sequence, expected):
'It matches a sequence against an expected result'
if 'name' in expecte... | if 'subject_strand' in expected: |
Continue the code snippet: <|code_start|> 'It test the blast parser'
def test_blast_parser(self):
'It test the blast parser'
blast_file = open(os.path.join(TEST_DATA_DIR, 'blast.xml'))
parser = BlastParser(fhand=blast_file)
expected_results = [
{'query':{'name':'cCL1... | 'length':629}, |
Using the snippet: <|code_start|> 'scores':{'expect': 2e-138,
'identity': 100.0}
},
],
}
],
}
]
n_blasts = 0
... | 'identity': 100.0} |
Using the snippet: <|code_start|> self.fail('Error expected')
except CalledProcessError:
assert 'No qualities available' in open(stderr.name).read()
# bad_format_fastq
bad_fastq_fhand = _make_fhand(FASTQ + 'aklsjhdas')
fasta_out_fhand = NamedTemporaryFile()
... | check_output([seqio_bin, '-o', fasta_out_fhand.name, '-f', 'fasta'], |
Given the code snippet: <|code_start|> for snv in snvs:
try:
self.write_snv(snv)
except IOError, error:
# The pipe could be already closed
if 'Broken pipe' in str(error):
break
else:
ra... | return ids[0] |
Given snippet: <|code_start|>
def windows(self):
chrom_lengths = self._get_chrom_lengths()
snp_queue = self._snp_queue
for chrom, chrom_length in chrom_lengths.items():
wins = generate_windows(start=0,
size=self.win_size, step=self.win_step,
... | self._snpcaller = None |
Predict the next line for this snippet: <|code_start|> snvs = self.pyvcf_reader.fetch(chrom, start + 1, end=end)
except KeyError:
snvs = []
if snvs is None:
snvs = []
for snp in snvs:
snp = SNV(snp, reader=self,
min_calls_for_... | elif 'freebayes' in metadata['source'][0].lower(): |
Continue the code snippet: <|code_start|> vcf_fhand = gzip.open(self._reader.fhand.name)
for line in vcf_fhand:
line = line.strip()
if line.startswith('#'):
continue
items = line.split()
chrom = items[0]
... | new_strech_start = snp_queue.queue[-1].pos + 1 |
Given the following code snippet before the placeholder: <|code_start|>
def _get_chrom_lengths(self):
chrom_lens = OrderedDict()
if self._ref_fhand is None:
vcf_fhand = gzip.open(self._reader.fhand.name)
for line in vcf_fhand:
line = line.strip()
... | snp_queue.empty() |
Given the following code snippet before the placeholder: <|code_start|># This file is part of seq_crumbs.
# seq_crumbs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at ... | def test_flag_to_binary(self): |
Given the code snippet: <|code_start|># This file is part of seq_crumbs.
# seq_crumbs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
... | def test_flag_to_binary(self): |
Next line prediction: <|code_start|>
# You should have received a copy of the GNU General Public License
# along with seq_crumbs. If not, see <http://www.gnu.org/licenses/>.
# pylint: disable=R0201
# pylint: disable=R0904
# pylint: disable=W0402
# pylint: disable=C0111
IS_PAIRED = SAM_FLAG_BITS['is_paired']
IS_IN_PR... | unittest.main() |
Continue the code snippet: <|code_start|>
def uppercase_length(string):
'It returns the number of uppercase characters found in the string'
return len(re.findall("[A-Z]", string))
def get_uppercase_segments(string):
'''It detects the unmasked regions of a sequence
It returns a list of (start, end) tu... | 'It changes the case of the seqrecords.' |
Predict the next line for this snippet: <|code_start|> desc = ''
desc += text
seqrecord.object.description = desc
class _FunctionRunner(object):
'a class to join all the mapper functions in a single function'
def __init__(self, map_functions):
'Class initiator'
self.map_function... | seq_packets = mapper(run_functions, seq_packets) |
Next line prediction: <|code_start|>
def uppercase_length(string):
'It returns the number of uppercase characters found in the string'
return len(re.findall("[A-Z]", string))
def get_uppercase_segments(string):
'''It detects the unmasked regions of a sequence
It returns a list of (start, end) tuples... | def __call__(self, seqs): |
Next line prediction: <|code_start|> str_seq = str_seq.lower()
elif action == SWAPCASE:
str_seq = str_seq.swapcase()
else:
raise NotImplementedError()
seq = copy_seq(seq, seq=str_seq)
processed_seqs.append(seq)
return... | return processed_packet |
Continue the code snippet: <|code_start|> desc = ''
desc += text
seqrecord.object.description = desc
class _FunctionRunner(object):
'a class to join all the mapper functions in a single function'
def __init__(self, map_functions):
'Class initiator'
self.map_functions = map_funct... | seq_packets = mapper(run_functions, seq_packets) |
Given snippet: <|code_start|>
# pylint: disable=R0903
# pylint: disable=C0111
def uppercase_length(string):
'It returns the number of uppercase characters found in the string'
return len(re.findall("[A-Z]", string))
def get_uppercase_segments(string):
'''It detects the unmasked regions of a sequence
... | 'The initiator' |
Based on the snippet: <|code_start|># Copyright 2012 Jose Blanca, Peio Ziarsolo, COMAV-Univ. Politecnica Valencia
# This file is part of seq_crumbs.
# seq_crumbs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation,... | AEGDFG5GGEGGF;EGD=D@>GCCGFFGGGCECFE:D@ |
Based on the snippet: <|code_start|># it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# seq_crumbs is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even t... | GATTGAAGCTCCAAACCGCCATGTTCACCACCGCAAGC |
Given snippet: <|code_start|># Copyright 2012 Jose Blanca, Peio Ziarsolo, COMAV-Univ. Politecnica Valencia
# This file is part of seq_crumbs.
# seq_crumbs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either... | TCATTACGTAGCTCCGGCTCCGCCATGTCTGTTCCTTC |
Based on the snippet: <|code_start|># Copyright 2012 Jose Blanca, Peio Ziarsolo, COMAV-Univ. Politecnica Valencia
# This file is part of seq_crumbs.
# seq_crumbs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation,... | + |
Next line prediction: <|code_start|># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with seq_crumbs. If not, see <http://www.gnu.org/licenses/>.
# pylint: disable=R0201
# pylint:... | AA=AF7CDEDAFFDF@5D>D;FCF;GGGDGGEGGGFGE |
Given snippet: <|code_start|># Copyright 2012 Jose Blanca, Peio Ziarsolo, COMAV-Univ. Politecnica Valencia
# This file is part of seq_crumbs.
# seq_crumbs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either... | AEGDFG5GGEGGF;EGD=D@>GCCGFFGGGCECFE:D@ |
Given the code snippet: <|code_start|># Copyright 2012 Jose Blanca, Peio Ziarsolo, COMAV-Univ. Politecnica Valencia
# This file is part of seq_crumbs.
# seq_crumbs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundatio... | + |
Continue the code snippet: <|code_start|># but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with seq_crumbs. If not, ... | + |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.